简体   繁体   English

面料JS; 如何使 object 无法移动,直到 object 被“完全”点击(鼠标向下和鼠标向上)

[英]Fabric JS; How to make an object unmovable until the object is "fully" clicked (mouse down and mouse up)

I am wondering if it is possible to make an object unmovable until it is "fully" clicked.我想知道是否可以使 object 在“完全”单击之前无法移动。 At the moment the object is movable as soon as it is selected, which is not great because it can lead to accidental movements.目前object一选就可以动,这不是很好,因为它会导致意外移动。 Is it possible to disable all movement of an object until it is fully clicked?是否可以禁用 object 的所有移动,直到它被完全点击? ie the user clicks the objects and releases the mouse so both onMouseDown and onMouseUp is triggered.即用户单击对象并释放鼠标,从而触发 onMouseDown 和 onMouseUp。

FabricJS vs 4.4.0 introduced a new object property called activeOn . FabricJS vs 4.4.0 引入了一个名为activeOn的新 object 属性。 By default, the value is 'down', meaning that objects are made active on mouse down/touch start.默认情况下,该值为“向下”,这意味着对象在鼠标向下/触摸开始时处于活动状态。 If you change the value to 'up', the object will only be made active after mouse up/touch end.如果将值更改为“向上”,则 object 将仅在鼠标向上/触摸结束后激活。 http://fabricjs.com/changelog http://fabricjs.com/changelog

fabric.Object.prototype.activeOn = "up";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM