Skip to content
Advertisement

fabricjs How can i keep fixed size on group elements while others scaling?

Hello I use fabricjs to play with the html canvas. I create the canvas and i add group of objects on it.

On a group of objects, I need to keep fixed width & height for some objects while I scale the object.

I use the ‘object:scaling’ event to get the active object when it changes size, I read each object of the group and I assign element[i].set({‘radius’:5}) on the group objects that I want to be unchanged.

But the result is that , all the group object to resize.

I show you the snippet of the object:scaling event :

JavaScript

What should I write into the for loop to keep fixed size on some objects? everything that I used above, they don’t work except for the “fill”:”#abcde2″,”stroke”:”#367827″

If anyone has faced something similar on fabricjs, please let me know .

Advertisement

Answer

You must use setScaleX() and setScaleY() methods. Here is an example…

JavaScript

JSFIDDLE

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement