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

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

Open
szager-chromium opened this issue Jul 22, 2021 · 2 comments

Comments

@szager-chromium
Copy link
Collaborator

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.

@comp615
Copy link

comp615 commented Sep 16, 2021

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

@SaidMarar
Copy link

SaidMarar commented Jul 19, 2023

@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

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

No branches or pull requests

3 participants