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

rootMargin not working until after the first time intersecting #495

Closed
stramel opened this issue Apr 1, 2021 · 9 comments · Fixed by #496
Closed

rootMargin not working until after the first time intersecting #495

stramel opened this issue Apr 1, 2021 · 9 comments · Fixed by #496
Labels
question Further information is requested

Comments

@stramel
Copy link

stramel commented Apr 1, 2021

Bug Report

Describe the Bug

The rootMargin is being ignore until after the first time the IntersectionObserver fires isIntersecting.

How to Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Provide custom rootMargin and custom ref
  2. Scroll down
  3. Observe the isIntersecting is false until the element is visible.
  4. Scroll down again
  5. Observe the isIntersecting is true at the expected rootMargin

CodeSandbox Link

https://codesandbox.io/s/react-cool-inviewissues495-0g4yk

Expected Behavior

Should respect the rootMargin on the initial scroll

Screenshots

image

Your Environment

  • Device: MacBook Pro
  • OS: macOS X
  • Browser: Chrome
  • Version: v1.2.2
@wellyshen
Copy link
Owner

@stramel Thank you for reporting this issue, I know the root cause, will fix it soon!

@wellyshen wellyshen added the bug Something isn't working label Apr 2, 2021
@stramel
Copy link
Author

stramel commented Apr 2, 2021

Thank you for reporting this issue, I know the root cause, will fix it soon!

Thanks! Just wanted to confirm that it is still an issue with v1.3.0 https://codesandbox.io/s/react-cool-inviewissues495-with-v130-zosed

@wellyshen
Copy link
Owner

wellyshen commented Apr 3, 2021

@stramel I copied your example to debug this issue with the latest version in my project (created by CRA) but I can not reproduce it, I'm not sure whether it only exists in the environment of the codesandbox (due to the issue of iframe) or not. Can it be reproduced in your project side?

@wellyshen wellyshen reopened this Apr 3, 2021
@wellyshen wellyshen added question Further information is requested and removed bug Something isn't working labels Apr 3, 2021
@stramel
Copy link
Author

stramel commented Apr 4, 2021

@wellyshen It does appear that it works properly in a CRA environment. So this probably isn't a bug with the library but maybe one with the browser's Intersection Observer implementation.

I did notice, that it looks like the state isn't reset properly?

image

The inView says true after the observe is called and the new ref has been set. As well as, the scrollDirection is resetting to 'up' even though I never scrolled up.

https://github.com/stramel/react-cool-inview-issue-495

@wellyshen
Copy link
Owner

@stramel That make sense, I will fix the scrollDirection part soon.

@wellyshen
Copy link
Owner

wellyshen commented Apr 4, 2021

@stramel The scrollDirection should be reset in v2.0.1.

@stramel
Copy link
Author

stramel commented Apr 4, 2021

Going to close this issue in favor of a new one to show the other issues that I have found with scrollDirection and inView.

@stramel stramel closed this as completed Apr 4, 2021
@wellyshen
Copy link
Owner

wellyshen commented Apr 4, 2021

@stramel Thank you bro, your issues really helpful.

@stramel
Copy link
Author

stramel commented Apr 4, 2021

Thanks for the cool 😎 library! 👍🏼

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

Successfully merging a pull request may close this issue.

2 participants