react-waypoint icon indicating copy to clipboard operation
react-waypoint copied to clipboard

When parent is hidden, it will fire onEnter callback anyway

Open moyus opened this issue 4 years ago • 1 comments

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

moyus avatar Jul 03 '20 04:07 moyus

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.

xyy94813 avatar Jan 28 '21 10:01 xyy94813