admin管理员组文章数量:1336660
I have 2 objects (images) in my canvas.
fc.item(0)
is a smaller image in the middle of the canvas. fc.item(1)
is a large image, "frame". The user can't move it. When the user's trying to move the fc.item(1)
, I wanna move the fc.item(0)
, as if the user's moved on the fc.item(1)
.
Any idea, how can I do this? I tried to use the fc.item(0).fire("object:moving")
, but this didn't work well.
I have 2 objects (images) in my canvas.
fc.item(0)
is a smaller image in the middle of the canvas. fc.item(1)
is a large image, "frame". The user can't move it. When the user's trying to move the fc.item(1)
, I wanna move the fc.item(0)
, as if the user's moved on the fc.item(1)
.
Any idea, how can I do this? I tried to use the fc.item(0).fire("object:moving")
, but this didn't work well.
- If i understand right, the solution is to move your lower indexed object manually while the selected object is moving. Find the diff (x,y) of the item1 center and add them to item0 center. – arty Commented Jan 8, 2014 at 23:59
1 Answer
Reset to default 10If you want to make top object unselectable just set its "selectable" to false
.
fc.item(1).selectable = false;
If you also want to propagate events to the bottom object (essentially "ignoring" top one), set top one's "evented" property to false
.
fc.item(1).evented = false;
本文标签: javascriptFabricjsMoving an object under the selected objectStack Overflow
版权声明:本文标题:javascript - Fabric.js - Moving an object under the selected object - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742333668a2455194.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论