Skip to content

Commit

Permalink
fix: resolve passive warning
Browse files Browse the repository at this point in the history
  • Loading branch information
linxianxi committed Jun 26, 2024
1 parent a4a01d7 commit 296c8e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,9 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
}

const componentEle = componentRef.current;
componentEle.addEventListener('wheel', onRawWheel);
componentEle.addEventListener('DOMMouseScroll', onFireFoxScroll as any);
componentEle.addEventListener('MozMousePixelScroll', onMozMousePixelScroll);
componentEle.addEventListener('wheel', onRawWheel, { passive: false });
componentEle.addEventListener('DOMMouseScroll', onFireFoxScroll as any, { passive: true });
componentEle.addEventListener('MozMousePixelScroll', onMozMousePixelScroll, { passive: false });

return () => {
componentEle.removeEventListener('wheel', onRawWheel);
Expand Down
12 changes: 6 additions & 6 deletions src/ScrollBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>

const scrollbarEle = scrollbarRef.current;
const thumbEle = thumbRef.current;
scrollbarEle.addEventListener('touchstart', onScrollbarTouchStart);
thumbEle.addEventListener('touchstart', onThumbMouseDown);
scrollbarEle.addEventListener('touchstart', onScrollbarTouchStart, { passive: false });
thumbEle.addEventListener('touchstart', onThumbMouseDown, { passive: false });

return () => {
scrollbarEle.removeEventListener('touchstart', onScrollbarTouchStart);
Expand Down Expand Up @@ -176,10 +176,10 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>
onStopMove();
};

window.addEventListener('mousemove', onMouseMove);
window.addEventListener('touchmove', onMouseMove);
window.addEventListener('mouseup', onMouseUp);
window.addEventListener('touchend', onMouseUp);
window.addEventListener('mousemove', onMouseMove, { passive: true });
window.addEventListener('touchmove', onMouseMove, { passive: true });
window.addEventListener('mouseup', onMouseUp, { passive: true });
window.addEventListener('touchend', onMouseUp, { passive: true });

return () => {
window.removeEventListener('mousemove', onMouseMove);
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useMobileTouchMove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export default function useMobileTouchMove(
touchYRef.current = Math.ceil(e.touches[0].pageY);

elementRef.current = e.target as HTMLElement;
elementRef.current.addEventListener('touchmove', onTouchMove);
elementRef.current.addEventListener('touchend', onTouchEnd);
elementRef.current.addEventListener('touchmove', onTouchMove, { passive: false });
elementRef.current.addEventListener('touchend', onTouchEnd, { passive: true });
}
};

Expand All @@ -82,7 +82,7 @@ export default function useMobileTouchMove(

useLayoutEffect(() => {
if (inVirtual) {
listRef.current.addEventListener('touchstart', onTouchStart);
listRef.current.addEventListener('touchstart', onTouchStart, { passive: true });
}

return () => {
Expand Down

0 comments on commit 296c8e2

Please sign in to comment.