fix drag&drop on mobile

This commit is contained in:
Anton Lavrenov
2019-02-27 09:14:07 -05:00
parent a62ce96214
commit 0d9a27f185
7 changed files with 1412 additions and 53 deletions

View File

@@ -494,6 +494,47 @@ suite('DragAndDrop', function() {
});
});
test('drag with touch', function() {
var stage = addStage();
var layer = new Konva.Layer();
var circle = new Konva.Circle({
x: 70,
y: 70,
radius: 70,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
name: 'myCircle',
draggable: true
});
layer.add(circle);
stage.add(layer);
circle.on('dragstart', function() {
assert.equal(circle.x(), 70);
assert.equal(circle.y(), 70);
});
stage.simulateTouchStart({
x: 70,
y: 70
});
stage.simulateTouchMove({
x: 100,
y: 100
});
stage.simulateTouchEnd({
x: 100,
y: 100
});
assert.equal(circle.x(), 100);
assert.equal(circle.y(), 100);
});
test('can stop drag on dragstart without changing position later', function() {
var stage = addStage();
var layer = new Konva.Layer();