Increase hold delay to 750ms and use Euclidean distance for cancellation

Use total distance (diagonal-aware) instead of per-axis thresholds
to better detect scrolling gestures that travel diagonally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
juan
2026-03-17 16:20:37 -07:00
parent 9bc166cb2a
commit 31a5ac156b

View File

@@ -113,11 +113,12 @@ export default class extends Controller {
const touchX = event.touches[0].clientX;
const touchY = event.touches[0].clientY;
// If hold hasn't activated yet, cancel it if user moves too far (they're scrolling)
// If hold hasn't activated yet, cancel if user moves too far (scrolling or swiping)
// Uses Euclidean distance to catch diagonal gestures too
if (!this.holdActivated) {
const dx = touchX - this.touchStartX;
const dy = touchY - this.touchStartY;
if (Math.abs(dx) > 10 || Math.abs(dy) > 10) {
if (dx * dx + dy * dy > 100) { // 10px radius
this.cancelHold();
}
return;