mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 02:21:20 +08:00
Fire pointerup for each pointer/add test for event order
This commit is contained in:
parent
615f35c804
commit
3a7d29279c
14
src/Stage.ts
14
src/Stage.ts
@ -732,12 +732,14 @@ export class Stage extends Container<Layer> {
|
||||
});
|
||||
|
||||
if (!triggeredOnShape) {
|
||||
this._fire(events.pointerup, {
|
||||
evt: evt,
|
||||
target: this,
|
||||
currentTarget: this,
|
||||
pointerId: this._changedPointerPositions[0].id,
|
||||
});
|
||||
for (const pointer of this._changedPointerPositions) {
|
||||
this._fire(events.pointerup, {
|
||||
evt: evt,
|
||||
target: this,
|
||||
currentTarget: this,
|
||||
pointerId: pointer.id,
|
||||
})
|
||||
}
|
||||
stageClickEvents.forEach(([e, evt]) => this._fire(e, evt))
|
||||
}
|
||||
|
||||
|
@ -343,6 +343,8 @@ describe('TouchEvents', function () {
|
||||
var stageTouchStart = 0;
|
||||
var stageTouchMove = 0;
|
||||
var stageTouchEnd = 0;
|
||||
var stageTap = 0;
|
||||
var stageEventStack: string[] = [];
|
||||
stage.on('touchstart', function () {
|
||||
stageTouchStart++;
|
||||
});
|
||||
@ -351,7 +353,12 @@ describe('TouchEvents', function () {
|
||||
});
|
||||
stage.on('touchend', function () {
|
||||
stageTouchEnd++;
|
||||
stageEventStack.push('touchend');
|
||||
});
|
||||
stage.on('tap', function () {
|
||||
stageTap++;
|
||||
stageEventStack.push('tap');
|
||||
})
|
||||
|
||||
// start with one touch
|
||||
simulateTouchStart(
|
||||
@ -452,6 +459,11 @@ describe('TouchEvents', function () {
|
||||
);
|
||||
assert.equal(touchEnd, 1);
|
||||
assert.equal(stageTouchEnd, 1);
|
||||
assert.equal(stageTap, 1);
|
||||
// Check that tap fires after touchend
|
||||
// (remember stacks are reverse event order)
|
||||
assert.equal(stageEventStack.pop(), 'tap', 'should fire tap after touchend')
|
||||
assert.equal(stageEventStack.pop(), 'touchend', 'should fire tap after touchend')
|
||||
|
||||
// try two touch ends on both shapes
|
||||
simulateTouchEnd(
|
||||
@ -465,8 +477,9 @@ describe('TouchEvents', function () {
|
||||
|
||||
assert.equal(touchEnd, 2);
|
||||
assert.equal(touchEnd2, 1);
|
||||
// TODO: it should be 2, not 3
|
||||
assert.equal(stageTouchEnd, 3);
|
||||
assert.equal(stageTap, 1)
|
||||
// Don't need to check event stack here, the pointers moved so no tap is fired
|
||||
});
|
||||
|
||||
it.skip('letting go of two fingers quickly should not fire dbltap', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user