Enable or disable Aspect Ratio lock

Any api reference to enable or disable aspect ratio lock of shape

No direct api here (as of until now), but you can get around with resize as:

function scaleByRatio(node, dimensions) {
    let bounds = node.localBounds,
        ratio = bounds.width / bounds.height

    for (var key in dimensions) {
        let dimension = dimensions[key]

        if (key == 'height') {
            node.resize(dimension * ratio, dimension);
        } else if (key == 'width') {
            node.resize(dimension, dimension / ratio);

// Usage:
// scaleByRatio(yourNode, {height: 700});
// scaleByRatio(yourNode, {width: 700});

@bantya Thanks for your code.

I already knew about this. Iā€™m looking for option that enable/disable lock button on panel. :grinning:

@realvjy there is no direct API to enable that feature. Please feel free to submit this as a feature request.

1 Like

Sure, will submit request