mirror of
https://github.com/konvajs/konva.git
synced 2025-12-21 19:27:08 +08:00
you can now cancel drag and drop with setDraggable(false) during a drag and drop operation
This commit is contained in:
20
src/Node.js
20
src/Node.js
@@ -36,12 +36,24 @@ Kinetic.Node = function(config) {
|
||||
this.setAttrs(config);
|
||||
|
||||
// bind events
|
||||
this.on('draggableChange.kinetic_reserved', function() {
|
||||
this.on('draggableChange.kinetic', function() {
|
||||
if(this.attrs.draggable) {
|
||||
this._listenDrag();
|
||||
}
|
||||
else {
|
||||
// remove event listeners
|
||||
this._dragCleanup();
|
||||
|
||||
/*
|
||||
* force drag and drop to end
|
||||
* if this node is currently in
|
||||
* drag and drop mode
|
||||
*/
|
||||
var stage = this.getStage();
|
||||
var go = Kinetic.GlobalObject;
|
||||
if(stage && go.drag.node && go.drag.node._id === this._id) {
|
||||
stage._endDrag();
|
||||
}
|
||||
}
|
||||
});
|
||||
/*
|
||||
@@ -734,7 +746,7 @@ Kinetic.Node.prototype = {
|
||||
this._dragCleanup();
|
||||
var go = Kinetic.GlobalObject;
|
||||
var that = this;
|
||||
this.on('mousedown.initdrag touchstart.initdrag', function(evt) {
|
||||
this.on('mousedown.kinetic_initdrag touchstart.kinetic_initdrag', function(evt) {
|
||||
that._initDrag();
|
||||
});
|
||||
},
|
||||
@@ -755,8 +767,8 @@ Kinetic.Node.prototype = {
|
||||
* remove drag and drop event listener
|
||||
*/
|
||||
_dragCleanup: function() {
|
||||
this.off('mousedown.initdrag');
|
||||
this.off('touchstart.initdrag');
|
||||
this.off('mousedown.kinetic_initdrag');
|
||||
this.off('touchstart.kinetic_initdrag');
|
||||
},
|
||||
/**
|
||||
* handle node event
|
||||
|
||||
Reference in New Issue
Block a user