w3c / IntersectionObserver

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

overflow-clip-margin or overflow-clip along one axis only on root or target #518

Open wangxianzhu opened 8 months ago

wangxianzhu commented 8 months ago

The spec (root intersection rect) says "An Element is defined as having a content clip if its computed style has overflow properties that cause its content to be clipped to the element’s padding edge. ... if the intersection root has a content clip ...".

However, if there is a non-zero overflow-clip-margin, or overflow-clip along one axis only, the clip doesn't clip the content to the padding edge. According to the current spec, the cases are not "having a content clip".

If we treat the cases as "having a content clip", we have the following choices for the root intersection rectangle:

  1. the padding box
  2. the client bounding box (i.e. the border box rect if the box is not fragmented)
  3. the clipping rect (in the case of overflow-clip only along one axis, the rect has infinite bounds in the unclipped direction)
  4. intersection of 2 and 3

The definition of the target bounding box also has an issue in the cases, but perhaps it's an issue with https://drafts.csswg.org/cssom-view-1/#element-get-the-bounding-box instead of intersection observer. Currently Chrome uses the union of the border box rect and the clip rect if there is effective overflow-clip-margin.