Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fabricjs - how can I unlock the aspect ratio

Tags:

fabricjs

As far as I can tell, when using a corner control to resize an object, the height and width are changed proportionally maintaining the objects aspect ratio regardless of where the user moves the mouse. My client wants the user to be able to adjust the height and width independently from the aspect ratio when using the corner controls. Is there a setting that will allow that?

like image 935
pthalacker Avatar asked Mar 03 '15 18:03

pthalacker


2 Answers

Just press the Shift key while scaling.

OR

You can adding this code:

canvas.uniScaleTransform = true;

EDIT:

the property is now called as of Fabric.js 4.0

canvas.uniformScaling = false;
like image 136
user2970115 Avatar answered Oct 24 '22 02:10

user2970115


By default, corner controls only resize and maintain aspect ratio.

You can turn off corner controls using setControlsVisibility, like this:

object.setControlsVisibility({
    tl: false, //top left
    tr: false, //top right
    bl: false, //bottom left
    br: false //bottom right
});

See this fiddle: http://jsfiddle.net/da7L0n1e/1/

like image 21
ptCoder Avatar answered Oct 24 '22 02:10

ptCoder