Re: [csswg-drafts] getVisibleClientRect API analogous to getBoundingClientRect (#13294)

> Any element can be used as an align target at any time. We cannot possibly add IntersectionObservers on every element and constantly track its intersection rectangle as it changes just in case something might want to align to it. The idea is ridiculous.

Well, there's no need to use that tone. I don't know how you API and I didn't suggest anything in particular.

My point was, is that API doing the computation you want (even if async)?

There are actually a lot of boxes you might care about, and a lot of ways of defining something as "visible". Just for a few examples: 

 * does opacity count? You can still hit test it.
 * What about the visibility property? That still creates a box that is positioned, and might have visible descendants.
 * Do you care about pre-transform or post-transform bounds?
 * Do you care about descendants of a given element that overflow?
 * What about absolutely positioned children that escape?
 * What about ancestor frames? Does an element report being visible even if its iframe is scrolled away? What if the iframe is cross-origin?
 * What if you're in a background tab?

I was just trying to scope your issue to something more concrete. IntersectionObserver does have answers for those questions.

If your issue can be reworded as "expose a sync version of IntersectionObserver", that is a much simpler thing to discuss than figuring out a complete new API. Does that make sense?

That said, while browsers indeed could have the capability of exposing this info synchronously, the whole reason IntersectionObserver was made async was because they are not simple computations, and people tend to shoot themselves in the foot with apis that force layout very often.

-- 
GitHub Notification of comment by emilio
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13294#issuecomment-3865004536 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Saturday, 7 February 2026 18:03:58 UTC