w3c / IntersectionObserver

Intersection Observer
https://www.w3.org/TR/intersection-observer/
Other
3.62k stars 523 forks source link

Intersection checks in IntersectionObserver should use ink overflow rect as the intersection rect #522

Open khushalsagar opened 6 months ago

khushalsagar commented 6 months ago

Forking from https://github.com/w3c/csswg-drafts/issues/7758#issuecomment-1995502030. The algorithm [here](https://w3c.github.io/IntersectionObserver/v2/#calculate-intersection-rect-algo:~:text=Let%20intersectionRect%20be%20the%20result%20of%20running%20the%20getBoundingClientRect()%20algorithm%20on%20the%20target.) uses the result of getBoundingClientRect() as the element's box to intersect against. It should be the element's ink overflow rect instead so expansion from properties like box-shadow, filter is included in calculating the element's visibility.

@szager-chromium

wangxianzhu commented 6 months ago

I don't think it's feasible to change the default behavior of IntersectonObserver at this time. IntersectionObserver v1 is designed to consider layout geometries mostly (perhaps except for clip-path?). Perhaps this will be a good topic for IntersectionObserver v2, or we should probably add a flag in IntersectionObserver API.

khushalsagar commented 6 months ago

Adding it as an opt-in would also be good. Other features (anchor-positioning/view-transitions) which are WIP can then default to this mode without compat risk.

@tabatkins fyi.