w3c/IntersectionObserver

Sub-pixel layout can cause intersectionRatio to be <1, even though target is entirely visible

szager-chromium opened this issue · 2 comments

First reported as a chromium bug:

https://bugs.chromium.org/p/chromium/issues/detail?id=1020466#c14

This is unexpected and useless behavior.

Off the top of my head: we could compute intersectionRatio based on pixel-snapped geometry. It would still be possible to derive intersectionRatio based on boundingClientRect and intersectionRect; but it would no longer be just a simple ratio of areas. It would also mean that in some cases (intersectionRatio == 1 && boundingClientRect != intersectionRect), which is also unintuitive.

For what it's worth, it turns out this can also cause intersectionRatio >= 0 to be fired even before an item comes onscreen

@szager-chromium This happen when display settings is big than 100%, so in my case i have 1.25 for window.devicePixelRatio

windows 10 display settings
image