civiccc/react-waypoint

When parent is hidden, it will fire onEnter callback anyway

Opened this issue · 1 comments

moyus commented

If I place <Waypoint /> in a hidden parent container, it will fire onEnter callback immediately as soon as it mounted, even if it's not in viewport. Which seems is a bug?

Here is the reproduce demo: https://codesandbox.io/s/react-waypoint-bug-nr0j4

We can refer to the Intersection Observer Polyfill

https://github.com/w3c/IntersectionObserver/blob/76ba9761eadab4091927b2497bfa13e59c9e25d8/polyfill/intersection-observer.js#L555-L570

first determines whether the element is displayed or not, and then calculates.