mirror of
https://github.com/imfing/hextra.git
synced 2025-09-15 12:01:59 -04:00
fix(image-zoom): disable dragging during single touch interactions
- Updated logic to prevent dragging when a single touch is detected, improving tap detection accuracy. - Adjusted event handling to ensure significant movement cancels tap only when necessary, enhancing user experience.
This commit is contained in:
@@ -99,8 +99,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (pointers.size === 1) {
|
if (pointers.size === 1) {
|
||||||
// Single touch - start drag
|
isDragging = false;
|
||||||
isDragging = true;
|
|
||||||
setInteracting(true);
|
setInteracting(true);
|
||||||
gestureState.lastPanX = gestureState.panX;
|
gestureState.lastPanX = gestureState.panX;
|
||||||
gestureState.lastPanY = gestureState.panY;
|
gestureState.lastPanY = gestureState.panY;
|
||||||
@@ -166,21 +165,12 @@
|
|||||||
// Any multi-touch movement cancels tap
|
// Any multi-touch movement cancels tap
|
||||||
tapCandidate = false;
|
tapCandidate = false;
|
||||||
applyTransform();
|
applyTransform();
|
||||||
} else if (isDragging && pointers.size === 1) {
|
} else if (pointers.size === 1) {
|
||||||
// Handle drag/pan
|
// Single pointer: no drag; only cancel tap if large move
|
||||||
const deltaX = pointer.x - pointer.startX;
|
|
||||||
const deltaY = pointer.y - pointer.startY;
|
|
||||||
|
|
||||||
gestureState.panX = gestureState.lastPanX + deltaX;
|
|
||||||
gestureState.panY = gestureState.lastPanY + deltaY;
|
|
||||||
|
|
||||||
// Significant movement cancels tap
|
|
||||||
const moveThreshold = 10;
|
const moveThreshold = 10;
|
||||||
if (Math.abs(pointer.x - tapStartX) > moveThreshold || Math.abs(pointer.y - tapStartY) > moveThreshold) {
|
if (Math.abs(pointer.x - tapStartX) > moveThreshold || Math.abs(pointer.y - tapStartY) > moveThreshold) {
|
||||||
tapCandidate = false;
|
tapCandidate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyTransform();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,9 +194,9 @@
|
|||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
} else if (pointers.size === 1) {
|
} else if (pointers.size === 1) {
|
||||||
// Going from pinch to single touch
|
// Going from pinch to single touch — keep dragging disabled
|
||||||
isPinching = false;
|
isPinching = false;
|
||||||
isDragging = true;
|
isDragging = false;
|
||||||
const remaining = Array.from(pointers.values())[0];
|
const remaining = Array.from(pointers.values())[0];
|
||||||
gestureState.lastPanX = gestureState.panX;
|
gestureState.lastPanX = gestureState.panX;
|
||||||
gestureState.lastPanY = gestureState.panY;
|
gestureState.lastPanY = gestureState.panY;
|
||||||
|
Reference in New Issue
Block a user