Drag

Drag:-

drag() API is used to define drag interactions on the layer. It extends the dom events to facilitate drag behavior. Drag interactions consist of 3 actions - dragStart, drag, dragEnd.

Syntax:

let dragInstance = i2d.behaviour.drag()

dragStart: Triggered on drag starts.

dragInstance.dragStart(function(event){

})

drag: Triggered continuously on drag. It will be triggered after dragStart till dragEnd.

dragInstance.drag(function(event){

})

dragEnd: Triggered once on drag ends.

dragInstance.dragEnd(function(event){

})

Usage:

let dragInstance = i2d.behaviour.drag()
dragInstance.dragStart(function (event) {
    node.setAttr('transform', event.transform);
});
dragInstance.drag(function (event) {
    node.setAttr('transform', event.transform);
});
dragInstance.dragEnd(function (event) {
    node.setAttr('transform', event.transform);
});

node.on('drag', dragInstance);

Last updated