最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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;
发布评论

评论列表(0)

  1. 暂无评论