fix event trigger flow. close #989

This commit is contained in:
Anton Lavrenov
2020-09-25 09:49:00 -05:00
parent 160b44b94d
commit 58f18c268a
4 changed files with 73 additions and 18 deletions

View File

@@ -144,6 +144,46 @@ suite('DragAndDrop', function () {
Konva.dragButtons = [0];
});
// ======================================================
test('changing draggable on mousedown should take effect', function () {
var stage = addStage();
var layer = new Konva.Layer();
var circle = new Konva.Circle({
x: stage.getWidth() / 2,
y: stage.getHeight() / 2,
radius: 70,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
name: 'myCircle',
});
layer.add(circle);
stage.add(layer);
circle.on('mousedown', () => {
circle.draggable(true);
});
stage.simulateMouseDown({
x: circle.x(),
y: circle.y(),
});
stage.simulateMouseMove({
x: circle.x() + 10,
y: circle.y() + 10,
});
assert.equal(circle.isDragging(), true);
stage.simulateMouseUp({
x: circle.x() + 10,
y: circle.y() + 10,
});
});
// ======================================================
test('while dragging do not draw hit', function () {
var stage = addStage();