mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 09:50:05 +08:00
fixed #348
This commit is contained in:
@@ -55,7 +55,34 @@ var Kinetic = {};
|
||||
*/
|
||||
isDragging: function() {
|
||||
var dd = Kinetic.DD;
|
||||
return (!dd || dd.isDragging);
|
||||
|
||||
// if DD is not included with the build, then
|
||||
// drag and drop is not even possible
|
||||
if (!dd) {
|
||||
return false;
|
||||
}
|
||||
// if DD is included with the build
|
||||
else {
|
||||
return dd.isDragging;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @method isDragReady returns whether or not a drag and drop operation is ready, but may
|
||||
* not necessarily have started
|
||||
* @methodOf Kinetic.Global
|
||||
*/
|
||||
isDragReady: function() {
|
||||
var dd = Kinetic.DD;
|
||||
|
||||
// if DD is not included with the build, then
|
||||
// drag and drop is not even possible
|
||||
if (!dd) {
|
||||
return false;
|
||||
}
|
||||
// if DD is included with the build
|
||||
else {
|
||||
return !!dd.node;
|
||||
}
|
||||
},
|
||||
warn: function(str) {
|
||||
/*
|
||||
|
@@ -412,8 +412,7 @@
|
||||
},
|
||||
_mousedown: function(evt) {
|
||||
this._setPointerPosition(evt);
|
||||
var dd = Kinetic.DD,
|
||||
go = Kinetic.Global,
|
||||
var go = Kinetic.Global,
|
||||
obj = this.getIntersection(this.getPointerPosition()),
|
||||
shape;
|
||||
|
||||
@@ -425,7 +424,7 @@
|
||||
}
|
||||
|
||||
//init stage drag and drop
|
||||
if(this.isDraggable() && !dd.node) {
|
||||
if(this.isDraggable() && !go.isDragReady()) {
|
||||
this.startDrag(evt);
|
||||
}
|
||||
},
|
||||
|
@@ -120,6 +120,10 @@ Test.Modules.DD = {
|
||||
});
|
||||
|
||||
testDataUrl(layer.toDataURL(), 'drag circle before', 'start data url is incorrect');
|
||||
|
||||
test(!Kinetic.Global.isDragging(), 'Global isDragging() should be false');
|
||||
test(!Kinetic.Global.isDragReady(), 'Global isDragReady()) should be false');
|
||||
|
||||
/*
|
||||
* simulate drag and drop
|
||||
*/
|
||||
@@ -133,11 +137,17 @@ Test.Modules.DD = {
|
||||
//test(!dragMove, 'dragmove event should not have been triggered');
|
||||
test(!dragEnd, 'dragend event should not have been triggered');
|
||||
|
||||
test(!Kinetic.Global.isDragging(), 'Global isDragging() should be false');
|
||||
test(Kinetic.Global.isDragReady(), 'Global isDragReady()) should be true');
|
||||
|
||||
stage._mousemove({
|
||||
clientX: 100,
|
||||
clientY: 98 + top
|
||||
});
|
||||
|
||||
test(Kinetic.Global.isDragging(), 'Global isDragging() should be true');
|
||||
test(Kinetic.Global.isDragReady(), 'Global isDragReady()) should be true');
|
||||
|
||||
test(dragStart, 'dragstart event was not triggered');
|
||||
//test(dragMove, 'dragmove event was not triggered');
|
||||
test(!dragEnd, 'dragend event should not have been triggered');
|
||||
@@ -155,6 +165,10 @@ Test.Modules.DD = {
|
||||
|
||||
test(events.toString() === 'mouseup,dragend', 'mouseup should occur before dragend');
|
||||
|
||||
|
||||
test(!Kinetic.Global.isDragging(), 'Global isDragging() should be false');
|
||||
test(!Kinetic.Global.isDragReady(), 'Global isDragReady()) should be false');
|
||||
|
||||
testDataUrl(layer.toDataURL(), 'drag circle after', 'end data url is incorrect');
|
||||
|
||||
showHit(layer);
|
||||
|
Reference in New Issue
Block a user