Enable or disable Aspect Ratio lock

feature-request

#1

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


#2

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});

#3

@bantya Thanks for your code.

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


#4

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


#5

Sure, will submit request