thomasf1
thomasf1

Reputation: 1804

Fabric.js: Is there a way to make the "move" listener fire when moved as part of a selection?

Is there a way to make the "move" listener fire when the object is moved as part of a selection?

rect2 = new fabric.Rect(
  left: 150
  top: 10
  fill: "green"
  width: 20
  height: 20
)

# Red&Green Rect: When moving "green", event fires, when moving both, it does not
rect2.on "moving", ->
    #Only fires when the object is moved on it´s own :(

jsFiddle -> http://jsfiddle.net/thomasf1/mJjH6/2/

Upvotes: 3

Views: 1878

Answers (1)

ubriaco
ubriaco

Reputation: 133

You can access all group objects via event.target._objects in canvas object:moving event. Note that fabric does not change child coordinates when moving group, so you should add child left coordinate to group left coordinate to get real left position.

Look at my jsFiddle example

Upvotes: 3

Related Questions