简体   繁体   中英

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. 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/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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