mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 16:31:14 +01:00
[gpu] Skip first touchmove after finger count change
Prevents jumps during 3→2→1 finger transitions by dropping one frame and reinitializing pinch state for the new finger count. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
dac2716b2a
commit
d8f1c44fd3
2 files changed
+32
No files matched your search
@@ -207,12 +207,14 @@ tap: animate · dbl-tap+drag: zoom · long-press: reset</span>
|
||||
var pinchAngle = 0;
|
||||
var pinchCX = 0, pinchCY = 0;
|
||||
var threeFingerActive = false;
|
||||
var touchCountChanged = false;
|
||||
var longPressTimer = null;
|
||||
var longPressFired = false;
|
||||
var lastTapTime = 0;
|
||||
var doubleTapZoom = false;
|
||||
var doubleTapY = 0;
|
||||
canvas.addEventListener('touchstart', function (e) {
|
||||
touchCountChanged = true;
|
||||
if (e.touches.length === 1) {
|
||||
var now = performance.now();
|
||||
if (now - lastTapTime < 300) {
|
||||
@@ -262,6 +264,18 @@ tap: animate · dbl-tap+drag: zoom · long-press: reset</span>
|
||||
}, {passive: false});
|
||||
var longPressX = 0, longPressY = 0;
|
||||
canvas.addEventListener('touchmove', function (e) {
|
||||
if (touchCountChanged) {
|
||||
touchCountChanged = false;
|
||||
/* Reinitialize state for current finger count to avoid jumps */
|
||||
if (e.touches.length === 2) {
|
||||
var t = e.touches;
|
||||
pinchDist = Math.hypot(t[1].clientX - t[0].clientX, t[1].clientY - t[0].clientY);
|
||||
pinchAngle = Math.atan2(t[1].clientY - t[0].clientY, t[1].clientX - t[0].clientX);
|
||||
pinchCX = (t[0].clientX + t[1].clientX) / 2;
|
||||
pinchCY = (t[0].clientY + t[1].clientY) / 2;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (longPressTimer && e.touches.length === 1) {
|
||||
var dx = e.touches[0].clientX - longPressX;
|
||||
var dy = e.touches[0].clientY - longPressY;
|
||||
@@ -316,6 +330,7 @@ tap: animate · dbl-tap+drag: zoom · long-press: reset</span>
|
||||
}
|
||||
}, {passive: false});
|
||||
canvas.addEventListener('touchend', function (e) {
|
||||
touchCountChanged = true;
|
||||
if (longPressTimer) { clearTimeout(longPressTimer); longPressTimer = null; }
|
||||
if (longPressFired) {
|
||||
longPressFired = false;
|
||||
|
||||
Reference in new issue
Block a user