Skip to content

Commit b5d09d9

Browse files
[css-anchor-position-1] Make snapshotted scroll offset per-axis (#9347)
Co-authored-by: Tab Atkins Jr <jackalmage@gmail.com>
1 parent 5c1c227 commit b5d09d9

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

css-anchor-position-1/Overview.bs

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,9 @@ of the fragments' border boxes is used instead.
470470
Issue: Do we need to control which box we're referring to,
471471
so you can align to padding or content edge?
472472

473-
If the positioned element
474-
has a [=snapshotted scroll offset=],
475-
then it is additionally visually shifted
476-
by those offsets,
473+
The positioned element
474+
is additionally visually shifted
475+
by its [=snapshotted scroll offset=],
477476
as if by an additional ''translate()'' transform.
478477

479478
<div class=example>
@@ -728,28 +727,47 @@ the performance benefits of the separate scrolling thread,
728727
we define:
729728

730729
<div algorithm="compensate for scroll">
731-
For any [=absolutely-positioned=] element |query el|,
732-
if there is a [=target anchor element=]
733-
given the [=default anchor specifier=] of |query el|,
734-
and at least one ''anchor()'' function on |query el|
735-
refers to the same [=target anchor element=],
736-
then |query el| has a <dfn>snapshotted scroll offset</dfn>,
737-
which is a pair of lengths
738-
representing a vertical and horizontal offset.
739-
740-
The [=snapshotted scroll offset=]
741-
is the sum of the offsets from the [=initial scroll position=]
742-
of all [=scroll container=] ancestors of the [=target anchor element=],
743-
up to but not including |query el|'s [=containing block=].
730+
An [=absolutely-positioned=] element |query el|
731+
<dfn>needs scroll adjustment</dfn>
732+
in the horizontal or vertical axis
733+
if both of the following conditions are true:
734+
735+
* |query el| has a [=default anchor element=].
736+
737+
* At least one ''anchor()'' function on |query el|'s
738+
used [=inset properties=] in the axis
739+
refers to a [=target anchor element=]
740+
with the same nearest [=scroll container=] ancestor
741+
as |query el|'s [=default anchor element=],
742+
or |query el|'s used [=self-alignment property=] value
743+
in the axis is ''anchor-center''.
744+
745+
Note: If |query el| has a [=position fallback list=],
746+
then whether it [=needs scroll adjustment=] in an axis
747+
is also affected by the applied fallback style.
748+
749+
|query el|'s <dfn>snapshotted scroll offset</dfn> is a pair of lengths
750+
for the horizontal and vertical axises, respectively.
751+
Each length is calculated as:
752+
753+
* If |query el| [=needs scroll adjustment=] in the axis,
754+
then the length is the sum of the [=scroll offsets=]
755+
of all [=scroll container=] ancestors
756+
of the [=default anchor element=]
757+
in the same axis,
758+
up to but not including |query el|'s [=containing block=];
759+
760+
* Otherwise, the length is 0.
744761

745762
Issue: Define the precise timing of the snapshot:
746763
updated each frame,
747764
before style recalc.
748765

749766
If |query el| has an [=additional fallback-bounds rect=],
750-
similarly calculate the sum of the offsets from the [=initial scroll position=]
767+
similarly calculate the sum of [=scroll offsets=]
751768
of all [=scroll container=] ancestors
752769
of the element generating the [=additional fallback-bounds rect=],
770+
up to but not including |query el|'s [=containing block=],
753771
and subtract that summed offset
754772
from the [=additional fallback-bounds rect's=] position.
755773
</div>
@@ -1088,8 +1106,7 @@ to trigger automatic "animation" of the fallback'd properties.
10881106
Let |adjusted styles|
10891107
be |el|'s styles after these adjustments.
10901108

1091-
2. If |el| has a [=snapshotted scroll offset=],
1092-
then subtract the offsets
1109+
2. Subtract |el|'s [=snapshotted scroll offset=]
10931110
from |el|'s margin box's position.
10941111

10951112
Also, if any of |el|'s [=inset properties=] are non-auto,

0 commit comments

Comments
 (0)