fix pointerleave bubbling

This commit is contained in:
Anton Lavrenov
2025-06-05 16:13:49 -05:00
parent f00fd70756
commit cdd61d7179
2 changed files with 46 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import {
simulateTouchStart,
simulateTouchMove,
simulateTouchEnd,
simulatePointerMove,
compareCanvases,
createCanvas,
showHit,
@@ -1222,6 +1223,36 @@ describe('Stage', function () {
assert.equal(count, 2);
});
it('stage pointerleave should not fire when leaving a child', function () {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
var circle = new Konva.Circle({
fill: 'red',
radius: 30,
x: 50,
y: 50,
});
layer.add(circle);
layer.draw();
var stageLeave = 0;
var circleLeave = 0;
stage.on('pointerleave', function () {
stageLeave += 1;
});
circle.on('pointerleave', function () {
circleLeave += 1;
});
simulatePointerMove(stage, { x: 50, y: 50 });
simulatePointerMove(stage, { x: 90, y: 50 });
assert.equal(circleLeave, 1, 'circle pointerleave should fire');
assert.equal(stageLeave, 0, 'stage pointerleave should not fire');
});
it('toDataURL with hidden layer', function () {
var stage = addStage();
var layer = new Konva.Layer();