简体   繁体   English

使Fabric.js对象可拖动但不“可选”

[英]Make Fabric.js object draggable but not “selectable”

Fabric.js has 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. Fabric.js有这个非常酷的方面,默认情况下它允许所有对象都是“可选择的”,这意味着它们可以被拖动,调整大小和旋转。 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. 如果需要的话,我不介意与源码混淆,这比自己重新实现更好。

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;

on creation pass following options to object: 在创建时传递以下对象的选项:

hasBorders: false
hasControls: false
hasRotatingPoint: false

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

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