Re: [csswg-drafts] [css-anchor-position] Better handling of scroll position for fixpos elements on first layout (#10999)

> Okay, first draft of the new spec text committed. It was a larger change than I thought it would be at first, but I think this captures the behavior we wanted (and is slightly better, in fact), while still respecting the scrolling-response constraints that Anchor Pos has to respect.
> 
> In short:
> 
> * When an anchor-pos element is first laid out, or switches to new fallback styles, it remembers the relative scroll offset of _each_ of its anchor references. From then on, it pretends that all scrollers are at their initial scroll position (same as the old spec) and adds the remembered scroll offset for that reference (new). This gets reflected into anchor().

What's the definition of first laid out? With container queries and scroll timelines there may be multiple passes where a box flips between being rendered and not in different passes during the same rendering update. getComputedStyle().width forces a layout, but should probably not be counted as "first laid out".

I think it would make sense to snapshot the scroll position as part of ["run snapshot post-layout state steps"](https://drafts.csswg.org/cssom-view/#run-snapshot-post-layout-state-steps), and probably consider the element as "first laid out" for the whole resizeObserver loop in https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model to account for changing scroll offsets (I'm assuming a position for "run snapshot post-layout state steps" after the "Recalculate styles and update layout for doc" which is something that was discussed at TPAC).


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


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

Received on Wednesday, 23 October 2024 08:12:59 UTC