fix: Improve drag threshold handling in useInertialHorizontalScroll hook
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user