Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve passive warning #281

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading