Skip to content

Commit

Permalink
onWheel is a passive listener
Browse files Browse the repository at this point in the history
onWheel should be a passive listener so it does not significantly slow down scrolling. It also resolves issue react-component#425 such that Chrome does not log a message to the console:
```
useTouchMove.js:154 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
```
  • Loading branch information
rickwargo authored Dec 14, 2022
1 parent 8057e38 commit 5e20870
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hooks/useTouchMove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default function useTouchMove(

// No need to clean up since element removed
ref.current.addEventListener('touchstart', onProxyTouchStart, { passive: false });
ref.current.addEventListener('wheel', onProxyWheel);
ref.current.addEventListener('wheel', onProxyWheel, { passive: true });

return () => {
document.removeEventListener('touchmove', onProxyTouchMove);
Expand Down

0 comments on commit 5e20870

Please sign in to comment.