klenium
klenium

Reputation: 2607

Fabric.js - Moving an object under the selected object

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.

Upvotes: 3

Views: 2822

Answers (1)

kangax
kangax

Reputation: 39168

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;

Upvotes: 10

Related Questions