Skip to content

Commit

Permalink
fix: fix error of tap in gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
xile611 committed Nov 7, 2024
1 parent ba1ac22 commit 507d349
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions packages/vrender-kits/src/event/extension/gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,30 @@ export class Gesture extends EventEmitter {
endEvent.velocity = velocity;
endEvent.direction = calcDirection(prevMovePoint, lastMovePoint);
this.triggerEvent('swipe', endEvent);

this.cachedEvents = [];
this.startPoints = [];
this.reset();
return;
}
}
}

if (now - this.lastTapTime < this.config.tap.interval && ev.target === this.lastTapTarget) {
this.tapCount++;
} else {
this.tapCount = 1;
}
this.lastTapTime = now;
this.lastTapTarget = ev.target;

if (this.tapCount === 1) {
this.triggerEvent('tap', endEvent);
} else if (this.tapCount === 2) {
this.triggerEvent('doubletap', endEvent);
this.tapCount = 0; // reset tapCount after doubletap
if (now - this.startTime < this.config.press.time) {
if (now - this.lastTapTime < this.config.tap.interval && ev.target === this.lastTapTarget) {
this.tapCount++;
} else {
this.tapCount = 1;
}
this.lastTapTime = now;
this.lastTapTarget = ev.target;

if (this.tapCount === 1) {
this.triggerEvent('tap', endEvent);
} else if (this.tapCount === 2) {
this.triggerEvent('doubletap', endEvent);
this.tapCount = 0; // reset tapCount after doubletap
}
}
}

Expand Down

0 comments on commit 507d349

Please sign in to comment.