javascript 使 Fabric.js 对象可拖动但不可“选择”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14842877/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Make Fabric.js object draggable but not "selectable"
提问by Zwade
Fabric.jshas this really cool aspect where it allows, by default, all objects to be "selectable", which means they are able to be dragged, resized, and rotated. However, I would like for them to be draggable only, no resizing or rotating. Is this possible? I don't mind mucking with the source if that is what's needed, it would be better than reimplementing it myself.
Fabric.js有一个非常酷的方面,默认情况下,它允许所有对象都是“可选择的”,这意味着它们可以被拖动、调整大小和旋转。但是,我希望它们只能拖动,不能调整大小或旋转。这可能吗?如果需要的话,我不介意破坏源代码,这比自己重新实现要好。
回答by Zwade
Nevermind, I have found the answer here: http://fabricjs.com/customization/
没关系,我在这里找到了答案:http: //fabricjs.com/customization/
This is the line that does it
这是这样做的线
canvas.item(0).hasControls = false;
回答by rdo
on creation pass following options to object:
在创建时将以下选项传递给对象:
hasBorders: false
hasControls: false
hasRotatingPoint: false