mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
made a better fix for the mobile alternating drag and drop bug
This commit is contained in:
15
dist/kinetic-core.js
vendored
15
dist/kinetic-core.js
vendored
@@ -1971,7 +1971,7 @@ Kinetic.Stage.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle touchstart
|
// handle touchstart
|
||||||
if(!isDragging && this.touchStart) {
|
if(!isDragging && this.touchStart && !this.touchMove) {
|
||||||
this.touchStart = false;
|
this.touchStart = false;
|
||||||
this.tapStart = true;
|
this.tapStart = true;
|
||||||
shape._handleEvent('touchstart', evt);
|
shape._handleEvent('touchstart', evt);
|
||||||
@@ -2176,7 +2176,8 @@ else if(!isDragging && this.touchMove) {
|
|||||||
var tt = 1000 / throttle;
|
var tt = 1000 / throttle;
|
||||||
|
|
||||||
if(timeDiff >= tt) {
|
if(timeDiff >= tt) {
|
||||||
that.mouseMove = true;
|
that.mouseDown = false;
|
||||||
|
that.mouseUp = false;
|
||||||
that._handleStageEvent(evt);
|
that._handleStageEvent(evt);
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
@@ -2228,9 +2229,19 @@ else if(!isDragging && this.touchMove) {
|
|||||||
var tt = 1000 / throttle;
|
var tt = 1000 / throttle;
|
||||||
|
|
||||||
if(timeDiff >= tt) {
|
if(timeDiff >= tt) {
|
||||||
|
/*
|
||||||
|
* need a setTimeout here because iOS
|
||||||
|
* sometimes triggers touchStart and touchMove
|
||||||
|
* simultaenously which causes eventd detection issues.
|
||||||
|
* The timeout ensures that touchstart events
|
||||||
|
* are handled first followed by touchmove
|
||||||
|
*/
|
||||||
|
setTimeout(function() {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
that.touchEnd = false;
|
||||||
that.touchMove = true;
|
that.touchMove = true;
|
||||||
that._handleStageEvent(evt);
|
that._handleStageEvent(evt);
|
||||||
|
}, 5);
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
15
src/Stage.js
15
src/Stage.js
@@ -422,7 +422,7 @@ Kinetic.Stage.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle touchstart
|
// handle touchstart
|
||||||
if(!isDragging && this.touchStart) {
|
if(!isDragging && this.touchStart && !this.touchMove) {
|
||||||
this.touchStart = false;
|
this.touchStart = false;
|
||||||
this.tapStart = true;
|
this.tapStart = true;
|
||||||
shape._handleEvent('touchstart', evt);
|
shape._handleEvent('touchstart', evt);
|
||||||
@@ -627,7 +627,8 @@ else if(!isDragging && this.touchMove) {
|
|||||||
var tt = 1000 / throttle;
|
var tt = 1000 / throttle;
|
||||||
|
|
||||||
if(timeDiff >= tt) {
|
if(timeDiff >= tt) {
|
||||||
that.mouseMove = true;
|
that.mouseDown = false;
|
||||||
|
that.mouseUp = false;
|
||||||
that._handleStageEvent(evt);
|
that._handleStageEvent(evt);
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
@@ -679,9 +680,19 @@ else if(!isDragging && this.touchMove) {
|
|||||||
var tt = 1000 / throttle;
|
var tt = 1000 / throttle;
|
||||||
|
|
||||||
if(timeDiff >= tt) {
|
if(timeDiff >= tt) {
|
||||||
|
/*
|
||||||
|
* need a setTimeout here because iOS
|
||||||
|
* sometimes triggers touchStart and touchMove
|
||||||
|
* simultaenously which causes eventd detection issues.
|
||||||
|
* The timeout ensures that touchstart events
|
||||||
|
* are handled first followed by touchmove
|
||||||
|
*/
|
||||||
|
setTimeout(function() {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
that.touchEnd = false;
|
||||||
that.touchMove = true;
|
that.touchMove = true;
|
||||||
that._handleStageEvent(evt);
|
that._handleStageEvent(evt);
|
||||||
|
}, 5);
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
@@ -1310,6 +1310,7 @@ Test.prototype.tests = {
|
|||||||
//log('not dragging yet after draggable, isDragging: ' + circle.isDragging());
|
//log('not dragging yet after draggable, isDragging: ' + circle.isDragging());
|
||||||
test(circle.isDragging() === false, 'isDragging() should be false');
|
test(circle.isDragging() === false, 'isDragging() should be false');
|
||||||
|
|
||||||
|
/*
|
||||||
circle.on('dragstart', function() {
|
circle.on('dragstart', function() {
|
||||||
log('dragstart, isDragging: ' + this.isDragging());
|
log('dragstart, isDragging: ' + this.isDragging());
|
||||||
test(circle.isDragging() === true, 'isDragging() should be true');
|
test(circle.isDragging() === true, 'isDragging() should be true');
|
||||||
@@ -1324,6 +1325,7 @@ Test.prototype.tests = {
|
|||||||
log('dragend, isDragging: ' + this.isDragging());
|
log('dragend, isDragging: ' + this.isDragging());
|
||||||
test(circle.isDragging() === false, 'isDragging() should be false');
|
test(circle.isDragging() === false, 'isDragging() should be false');
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
layer.add(circle);
|
layer.add(circle);
|
||||||
stage.add(layer);
|
stage.add(layer);
|
||||||
|
Reference in New Issue
Block a user