fabricjs - How to get individual object's width, height, left and top in selection:created event? -
i getting values of properties of object(top,width...) object being scaled/moved using function :
canvas.on('object:scaling', onobjectmodification); canvas.on('object:moving', onobjectmodification); canvas.on('object:rotating', onobjectmodification); function onobjectmodification(e) { var activeobject = e.target; var reachedlimit = false; objectleft = activeobject.left, objecttop = activeobject.top, objectwidth = activeobject.width, objectheight = activeobject.height, canvaswidth = canvas.width, canvasheight = canvas.height; } how can same each object being moved group? need values changing object:scaling event provide.
i know of event selection:created lost how use attain want. guys highly appreciated. thanks
during object scaling width , height not change. same time, scalex , scaley change.
you have write function iterate on possibile group sub objects.
canvas.on('object:scaling', onobjectmodification); canvas.on('object:moving', onobjectmodification); canvas.on('object:rotating', onobjectmodification); function onobjectmodification(e) { var activeobject = e.target; if (!activeobject) { return; } var canvaswidth = canvas.width; var canvasheight = canvas.height; var reachedlimit = false; var objectleft = activeobject.left; var objecttop = activeobject.top; // provide scaled height , width var objectwidth = activeobject.getwidth(); var objectheight = activeobject.getheight(); if (activeobject._objects) { objs = activeobject._objects; (var i= 0; < objs.length; i++) { var obj = objs[i]; var objwidth = activeobject.getwidth() * activeobject.scalex; var objheight = activeobject.getheight() * activeobject.scaley; } } }
Comments
Post a Comment