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

Clipping ignored due to "containing block" usage #505

Open
jakearchibald opened this issue Nov 28, 2022 · 3 comments
Open

Clipping ignored due to "containing block" usage #505

jakearchibald opened this issue Nov 28, 2022 · 3 comments

Comments

@jakearchibald
Copy link
Contributor

https://static-misc-3.glitch.me/scroll-layout-test/intersection-demo-reduced.html

In this demo, a position: fixed element and a position: absolute element is entirely clipped by its parent.

Chrome: Neither intersecting.
Firefox & Safari: Both intersecting.

It seems like Firefox & Safari are getting it right according to the spec, but it's probably the spec that's wrong, since Chrome's result seems the most reasonable.

The problem in the spec is here I think: https://w3c.github.io/IntersectionObserver/#compute-the-intersection

Let container be the containing block of target.

The problem here is that the "containing block" for absolute & fixed elements 'skips over' the element that's causing the clipping.

I think the spec needs to be updated so that clip-path on all ancestor elements is considered. However, overflow clipping should be ignored unless it's part of the containing block chain.

@jakearchibald
Copy link
Contributor Author

@emilio @annevk would you be happy with a spec change & tests that defines what Chrome is doing here? It seems to match the intent of the feature.

@emilio
Copy link
Collaborator

emilio commented Nov 29, 2022

Firefox doesn't take clip-path into account for IntersectionObserver, that's bug 1319140. But yeah, the spec seems wrong.

@wangxianzhu
Copy link

@szager-chromium Actually Chrome's behavior is not consistent. It uses two code paths to calculate the intersection rect. The mostly used code path supports css clips, clip-paths and masks, while the other rarely used code path doesn't. How about keeping the current spec, and changing chrome to ignore css clips, clip-paths and masks? These things don't follow the containing block chain, amd make things complicated and difficult to optimize unnecessary intersection computations. It seems good to make intersection observer v1 just to consider overflow clips because v2 will consider them in visibility.

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