fix bug for touchend event. close #156

This commit is contained in:
Anton Lavrenov
2016-07-05 09:04:18 +07:00
parent 9b56d7004e
commit 8004687541
5 changed files with 66 additions and 6 deletions

View File

@@ -235,4 +235,59 @@ suite('TouchEvents', function() {
done();
}, 17);
});
});
// test for https://github.com/konvajs/konva/issues/156
test("touchstart out of shape, then touch end inside shape", function() {
var stage = addStage();
var layer = new Konva.Layer();
var circle = new Konva.Circle({
x: 100,
y: 100,
radius: 70,
fill: 'green',
stroke: 'black',
strokeWidth: 4,
name: 'myCircle'
});
layer.add(circle);
stage.add(layer);
var circleTouchend =
stageContentTouchstart =
stageContentTouchend =
0;
var top = stage.content.getBoundingClientRect().top;
circle.on('touchend', function() {
circleTouchend++;
});
stage.on('contentTouchstart', function() {
stageContentTouchstart++;
});
stage.on('contentTouchend', function() {
stageContentTouchend++;
});
stage._touchstart({
touches: [{
clientX: 1,
clientY: 1 + top
}]
});
stage._touchend({
touches: [{
clientX: 100,
clientY: 100 + top
}]
});
assert.equal(stageContentTouchstart, 1);
assert.equal(stageContentTouchend, 1);
assert.equal(circleTouchend, 1);
});
});