Skip to content

Commit 9c0857a

Browse files
committed
fix: Not block touch event when out of virtual
1 parent ce53be3 commit 9c0857a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/List.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
217217
});
218218

219219
// Mobile touch move
220-
useMobileTouchMove(componentRef, deltaY => {
220+
useMobileTouchMove(inVirtual, componentRef, deltaY => {
221221
onRawWheel({ preventDefault() {}, deltaY } as WheelEvent);
222222
});
223223

src/hooks/useMobileTouchMove.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useRef } from 'react';
44
const SMOOTH_PTG = 14 / 15;
55

66
export default function useMobileTouchMove(
7+
inVirtual: boolean,
78
listRef: React.RefObject<HTMLDivElement>,
89
callback: (offsetY: number) => void,
910
) {
@@ -67,12 +68,14 @@ export default function useMobileTouchMove(
6768
};
6869

6970
React.useEffect(() => {
70-
listRef.current.addEventListener('touchstart', onTouchStart);
71+
if (inVirtual) {
72+
listRef.current.addEventListener('touchstart', onTouchStart);
73+
}
7174

7275
return () => {
7376
listRef.current.removeEventListener('touchstart', onTouchStart);
7477
cleanUpEvents();
7578
clearInterval(intervalRef.current);
7679
};
77-
}, []);
80+
}, [inVirtual]);
7881
}

0 commit comments

Comments
 (0)