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

标签 javascript fabricjs

有没有办法让“移动”监听器在对象作为选择的一部分移动时触发?

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/

最佳答案

您可以通过 event.target._objects 在 Canvas object:moving 事件中访问所有组对象。请注意,fabric 在移动组时不会更改子坐标,因此您应该将子左坐标添加到组左坐标以获得真正的左位置。

看看我的jsFiddle例子

关于javascript - Fabric .js : Is there a way to make the "move" listener fire when moved as part of a selection?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24306659/

相关文章:

javascript - 类型继承: Why do you have to create a new object instead of setting the prototype directly?

javascript - Angularjs:所有代码(html、js)都是最初加载还是根据请求发生

javascript - 为每个返回的元素获取一个 div

javascript - 在 chrome/webkit 中使用 XSLT 转换 HTML 节点

javascript - 调整图像大小后,减少由fabric.js序列化的JSON的大小

javascript - Fabric.js 中特定字符的文本高度

fabricjs - 如何将 Canvas 的原点放在中心

JavaScript - 创建一些可用于为表格行提供替代样式的 CSS 类

javascript - FabricJS 层

javascript - 当 Canvas 重新定位时,Fabric.js Canvas 坐标的值会发生变化