GoogleChrome / samples

A repo containing samples tied to new functionality in each release of Google Chrome.
https://www.chromestatus.com/samples
Apache License 2.0
5.77k stars 2.38k forks source link

intersectionObserver sample code issue #746

Open joekingTheThird3 opened 2 years ago

joekingTheThird3 commented 2 years ago

https://googlechrome.github.io/samples/intersectionobserver/ I have found that the line 'if (entries.some(entry => entry.intersectionRatio > 0)) {' can cause some issues. The issue is that it is possible to get entry.intersectionRatio to be equal to 0 (zero), so it would fail and not add extra content. I have changed the comparison to entry.intersectionRatio >= 0 , That seems to be okay. The intersectionRatio even if zero is having the target element appear/disappear from the root element (by what I've read, even 1px causes the intersection).