Fixed double tap trigger after dragging. close #721

This commit is contained in:
Anton Lavrenov 2019-09-02 11:39:22 -05:00
parent 0e34a8c9ca
commit 4383e411b3
5 changed files with 69 additions and 5 deletions

View File

@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## Not released:
* Fixed double tap trigger after dragging
## 4.0.6 - 2019-08-31
* Fix fillPatternScale for text

View File

@ -8,7 +8,7 @@
* Konva JavaScript Framework v4.0.6
* http://konvajs.org/
* Licensed under the MIT
* Date: Sat Aug 31 2019
* Date: Mon Sep 02 2019
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@ -6252,7 +6252,7 @@
clearTimeout(this.dblTimeout);
// Konva.inDblClickWindow = false;
}
else {
else if (!DD.justDragged) {
Konva.inDblClickWindow = true;
clearTimeout(this.dblTimeout);
}

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -757,7 +757,7 @@ export class Stage extends Container<BaseLayer> {
fireDblClick = true;
clearTimeout(this.dblTimeout);
// Konva.inDblClickWindow = false;
} else {
} else if (!DD.justDragged) {
Konva.inDblClickWindow = true;
clearTimeout(this.dblTimeout);
}

View File

@ -561,4 +561,66 @@ suite('TouchEvents', function() {
assert.equal(tap, 2, 'tap triggered');
assert.equal(dbltap, 1, 'no dbltap triggered');
});
test('drag and second tap should not trigger dbltap', function() {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
var circle1 = new Konva.Circle({
x: 100,
y: 100,
radius: 70,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
name: 'myCircle1',
draggable: true
});
layer.add(circle1);
layer.draw();
var tap = 0;
var dbltap = 0;
var dragmove = 0;
stage.on('tap', e => {
assert.equal(e.target, circle1);
tap += 1;
});
stage.on('dbltap', e => {
dbltap += 1;
});
stage.on('dragmove', e => {
dragmove += 1;
});
stage.simulateTouchStart(
[{ x: 100, y: 100, id: 0 }],
[{ x: 100, y: 100, id: 0 }]
);
stage.simulateTouchMove(
[{ x: 150, y: 150, id: 0 }],
[{ x: 150, y: 150, id: 0 }]
);
stage.simulateTouchEnd([], [{ x: 150, y: 150, id: 0 }]);
assert.equal(tap, 0, 'no tap triggered');
assert.equal(dbltap, 0, 'no dbltap triggered');
assert.equal(dragmove, 1, 'dragmove triggered');
stage.simulateTouchStart(
[{ x: 150, y: 150, id: 0 }],
[{ x: 150, y: 150, id: 0 }]
);
stage.simulateTouchEnd([], [{ x: 150, y: 150, id: 0 }]);
assert.equal(tap, 1, 'tap triggered');
assert.equal(dbltap, 0, 'no dbltap triggered');
});
});