@@ -143,7 +143,12 @@ resolves to the <<length>>
143143that would align the edge
144144of the positioned elements' [=inset-modified containing block=]
145145corresponding to the property the function appears in
146- with the specified border edge of the [=target anchor element=] .
146+ with the specified border edge of the [=target anchor element=] ,
147+ assuming that all [=scroll containers=]
148+ between the [=target anchor element=]
149+ and the positioned element's [=containing block=]
150+ are scrolled to their initial scroll position
151+ (but see 'anchor-scroll' ).
147152
148153If the [=target anchor element=] is [=fragmented=] ,
149154the axis-aligned bounding rectangle
@@ -152,12 +157,11 @@ of the fragments' border boxes is used instead.
152157Issue: Do we need to control which box we're referring to,
153158so you can align to padding or content edge?
154159
155- Issue: Per flackr/iank feedback,
156- this should be able to respond to the scroll position
157- of the anchor element,
158- both for positioning and for fallback,
159- in a way essentially identical to @scroll-timeline.
160- Precise timing + details to be filled in.
160+ If the positioned element
161+ has a [=snapshotted scroll offset=] ,
162+ then it is additionally visually shifted
163+ by those offsets,
164+ as if by an additional ''translate()'' transform.
161165
162166<div class=example>
163167 For example,
@@ -267,6 +271,83 @@ whichever is in the specified axis)
267271of the [=target anchor element=] .
268272
269273
274+ <!-- Big Text: a-scroll -->
275+
276+ Taking Scroll Into Account: the 'anchor-scroll' property {#scroll}
277+ ------------------------------------------------------------------
278+
279+ <pre class=propdef>
280+ Name : anchor-scroll
281+ Value : none | <<dashed-ident>>
282+ Initial : none
283+ Inherited : no
284+ Applies to : [=absolutely-positioned=] elements
285+ Animation Type : discrete
286+ </pre>
287+
288+ Because scrolling is often done in a separate thread from layout in implementations for performance reasons,
289+ but ''anchor()'' can result in both positioning changes
290+ (which can be handled in the scrolling thread)
291+ and layout changes
292+ (which cannot),
293+ ''anchor()'' is defined to assume
294+ all the [=scroll containers=] between the anchor element
295+ and the positioned element's containing block
296+ are at their initial scroll position.
297+ This means a positioned element
298+ will <em> not</em> be aligned with its anchor
299+ if any of the scrollers are <em> not</em> at their initial positions.
300+
301+ The 'anchor-scroll' property allows an author to compensate for this,
302+ without losing the performance benefits of the separate scrolling thread,
303+ so long as the positioned element
304+ is only anchoring to a single anchor element.
305+ Its values are:
306+
307+ <dl dfn-type=value dfn-for=anchor-scroll>
308+ : <dfn>none</dfn>
309+ :: No effect.
310+
311+ : <dfn><<dashed-ident>></dfn>
312+ ::
313+ The scroll offsets of the [=target anchor element=]
314+ with the name given by the <<dashed-ident>>
315+ will be compensated for in positioning and fallback.
316+
317+ : <dfn>implicit</dfn>
318+ ::
319+ The scroll offsets of the [=implicit anchor element=]
320+ will be compensated for in positioning and fallback.
321+ </dl>
322+
323+ <div algorithm="compensate for scroll">
324+ If 'anchor-scroll' is not ''anchor-scroll/none''
325+ on an [=absolutely-positioned=] element |query el|,
326+ and there is a [=target anchor element=] for |query el|
327+ with either the name given by 'anchor-scroll'
328+ (if its value is a <<dashed-ident>> )
329+ or no name
330+ (if its value is ''implicit'' ),
331+ and at least one ''anchor()'' function on |query el|
332+ refers to the same [=target anchor element=] ,
333+ then |query el| has a <dfn>snapshotted scroll offset</dfn> ,
334+ which is a pair of lengths
335+ representing a vertical and horizontal offset.
336+
337+ The [=snapshotted scroll offset=]
338+ is the sum of the offsets from the [=initial scroll position=]
339+ of all [=scroll container=] ancestors of the [=target anchor element=] ,
340+ up to but not including |query el|'s [=containing block=] .
341+
342+ Issue: Define the precise timing of the snapshot:
343+ updated each frame,
344+ before style recalc.
345+ </div>
346+
347+
348+
349+
350+
270351<!--
271352 ███ ██ ██ ███ ██ ██ ████████
272353 ██ ██ ███ ██ ██ ██ ███ ███ ██
@@ -579,6 +660,9 @@ To determine which entry is selected,
579660[=list/iterate=] over the [=position fallback list=] ,
580661applying the properties of each entry in turn
581662according to the standard cascade rules,
663+ and additionally shifting the element's [=margin box=]
664+ according to its [=snapshotted scroll offset=]
665+ (if it has one),
582666and determining whether or not the element's [=margin box=]
583667overflows its [=containing block=] .
584668
0 commit comments