Skip to content

Window scroll event not fired #18299

Answered by mrgoonie
mrgoonie asked this question in Help
Oct 27, 2020 · 2 comments · 5 replies
Discussion options

You must be logged in to vote

Work around:

Add the scroll event listener into the body instead of the window or document

...
  const handleScroll = (e) => { console.log(e) };
  useEffect(() => {
    document.body.addEventListener('scroll', handleScroll);
    return () => document.body.removeEventListener('scroll', handleScroll);
  }, []);
...

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@rimzzlabs
Comment options

@risingstar9
Comment options

Answer selected by mrgoonie
Comment options

You must be logged in to vote
3 replies
@daltonmenezes
Comment options

@daltonmenezes
Comment options

@surajdhungana46
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #18299 on October 27, 2020 18:07.