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

InView is not working exactly #18

Open
alive-vietnam-ti opened this issue Oct 2, 2019 · 2 comments
Open

InView is not working exactly #18

alive-vietnam-ti opened this issue Oct 2, 2019 · 2 comments
Labels

Comments

@alive-vietnam-ti
Copy link

alive-vietnam-ti commented Oct 2, 2019

This module is great to handle the element in-view of a browser's viewport.
But I have a problem that you can see below the image.
It's not working exactly when I scrolling the browser.
The element is still not out of the screen has been toggle onNotInView.
"intoViewMargin" is a default value
How can I fix that?

inview

@pocketjoso
Copy link
Contributor

pocketjoso commented Oct 2, 2019

Hi, thanks for the kind words. :)

I think the settings you want for this case are:

  • intoViewMargin: 0% (or even 20%, a positive number)
  • threshold: 1
    Note that threshold was only added earlier this week, so you will need to make sure you update to the latest version of react-inview-monitor.

To understand threshold and intoViewMargin better, please see the MDN docs for IntersectionObserver, which is used under the hood:
https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
(note that what react-inview-monitor intoViewMargin maps to rootMargin in the IntersectionObserver api)

@pocketjoso
Copy link
Contributor

Although I'm not sure exactly how you are using react-inview-monitor - can you share the exact code for the InViewMonitor used here, with all the props you are sending it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants