Who can help me a little with JS Fabric move / drag function? I want the drag / move function triggered by de left top corner and I tried the code below:
//drag function
const dragOriginal = fabric.Object.prototype.controls.tl;
fabric.Object.prototype.controls.moveObject = new fabric.Control({
x: -0.5,
y: -0.5,
actionHandler: dragOriginal,
actionName: 'drag',
cursorStyle:'pointer',
render: renderIcon,
cornerSize: 25
});
This gives me the following error in the console
actionHandler is not a function. (In 'actionHandler(e, transform, x, y)', 'actionHandler' is an instance of Object)
Who can help me with this?
CodePudding user response:
I think this is the answer
fabric.Object.prototype.controls.moveObject = new fabric.Control({
x: -0.5,
y: -0.5,
actionHandler: fabric.controlsUtils.dragHandler,//change to this
actionName: 'drag',
cursorStyle:'pointer',
render: renderIcon,
cornerSize: 25
});
I hope this is were you looking for.