mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
fixed #348
This commit is contained in:
@@ -54,8 +54,35 @@ var Kinetic = {};
|
|||||||
* @methodOf Kinetic.Global
|
* @methodOf Kinetic.Global
|
||||||
*/
|
*/
|
||||||
isDragging: function() {
|
isDragging: function() {
|
||||||
var dd = Kinetic.DD;
|
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) {
|
warn: function(str) {
|
||||||
/*
|
/*
|
||||||
|
@@ -412,10 +412,9 @@
|
|||||||
},
|
},
|
||||||
_mousedown: function(evt) {
|
_mousedown: function(evt) {
|
||||||
this._setPointerPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var dd = Kinetic.DD,
|
var go = Kinetic.Global,
|
||||||
go = Kinetic.Global,
|
obj = this.getIntersection(this.getPointerPosition()),
|
||||||
obj = this.getIntersection(this.getPointerPosition()),
|
shape;
|
||||||
shape;
|
|
||||||
|
|
||||||
if(obj && obj.shape) {
|
if(obj && obj.shape) {
|
||||||
shape = obj.shape;
|
shape = obj.shape;
|
||||||
@@ -425,7 +424,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//init stage drag and drop
|
//init stage drag and drop
|
||||||
if(this.isDraggable() && !dd.node) {
|
if(this.isDraggable() && !go.isDragReady()) {
|
||||||
this.startDrag(evt);
|
this.startDrag(evt);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -120,6 +120,10 @@ Test.Modules.DD = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testDataUrl(layer.toDataURL(), 'drag circle before', 'start data url is incorrect');
|
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
|
* simulate drag and drop
|
||||||
*/
|
*/
|
||||||
@@ -133,11 +137,17 @@ Test.Modules.DD = {
|
|||||||
//test(!dragMove, 'dragmove event should not have been triggered');
|
//test(!dragMove, 'dragmove event should not have been triggered');
|
||||||
test(!dragEnd, 'dragend 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({
|
stage._mousemove({
|
||||||
clientX: 100,
|
clientX: 100,
|
||||||
clientY: 98 + top
|
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(dragStart, 'dragstart event was not triggered');
|
||||||
//test(dragMove, 'dragmove event was not triggered');
|
//test(dragMove, 'dragmove event was not triggered');
|
||||||
test(!dragEnd, 'dragend event should not have been 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(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');
|
testDataUrl(layer.toDataURL(), 'drag circle after', 'end data url is incorrect');
|
||||||
|
|
||||||
showHit(layer);
|
showHit(layer);
|
||||||
|
Reference in New Issue
Block a user