fix: Improve drag threshold handling in useInertialHorizontalScroll hook

This commit is contained in:
2026-05-17 17:07:49 +10:00
parent ba31d65568
commit 8de528da9a

View File

@@ -236,11 +236,18 @@ export function useInertialHorizontalScroll(
const deltaPrimary = currentPrimary - state.startPrimary;
const now = evt.timeStamp;
const deltaTime = Math.max(now - state.lastTime, 1);
const hasExceededThreshold = Math.abs(deltaPrimary) >= resolvedOptions.dragThreshold;
if (Math.abs(deltaPrimary) >= resolvedOptions.dragThreshold) {
if (hasExceededThreshold) {
state.moved = true;
}
if (!state.moved) {
state.lastPrimary = currentPrimary;
state.lastTime = now;
return;
}
evt.preventDefault?.();
if (isHorizontal) {
@@ -272,8 +279,6 @@ export function useInertialHorizontalScroll(
const isHorizontal = resolvedOptions.axis === 'x';
stopInertia();
evt.preventDefault();
evt.stopPropagation();
state.activePointerId = evt.pointerId;
state.startPrimary = isHorizontal ? evt.clientX : evt.clientY;