javascript - Fabric.js - Moving an object under the selected object - Stack Overflow

I have 2 objects (images) in my canvas.fc.item(0) is a smaller image in the middle of the canvas. fc.it

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.

Share Improve this question edited Jan 9, 2014 at 3:04 kangax 39.2k13 gold badges100 silver badges135 bronze badges asked Jan 8, 2014 at 15:04 kleniumklenium 2,6172 gold badges27 silver badges52 bronze badges 1
  • 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
Add a ment  | 

1 Answer 1

Reset to default 10

If 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;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742333668a4424219.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信