Skip to content

Commit

Permalink
[css-overflow-5] Treat the last scroll target as active
Browse files Browse the repository at this point in the history
When a targeted scroll is performed, use that target to determine the active scroll marker. Fixes w3c#10738.
  • Loading branch information
flackr committed Dec 3, 2024
1 parent 9a8ec95 commit ccebfb3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 18 deletions.
63 changes: 46 additions & 17 deletions css-overflow-5/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,28 @@ its content will be integrated into this specification,
which will then replace it.
Until then, this specification only contains additions and extensions to level 4.

<h2 id="overflow-concepts">
Overflow Concepts and Terminology</h2>

Issue: Copy [[css-overflow-3#overflow-concepts|Level 3 content]] when final.

<h3 id="scrolling">Scrolling overflow</h3>

The following is added to the concepts in scrolling overflow:

Every [=scroll container=] maintains a <dfn export>current scroll target</dfn>.
It is initially <code>null</code>,
and is reset to <code>null</code> after any scrolling operations in that [=scroll container=]
initiated by the user,
or any script initiated operations that do not have a target,
or when the target is removed from the document.
Scrolling operations in the [=scroll container=] with a target Element or PseudoElement,
set the [=current scroll target=] to that target Element or PseudoElement.

Issue: Setting the current scroll target should be defined in how to <a>scroll a target into view</a>.

Issue: Use the current scroll target as an <a>anchor priority candidate</a> for scroll anchoring.

<h2 id="scroll-navigation">
Scroll navigation controls</h2>

Expand Down Expand Up @@ -301,23 +323,30 @@ Selecting The Active Scroll Marker: the '':target-current'' pseudo-class</h4>
1. While |active| is a [=scroll container=] containing [=scroll target=] elements targeted by |group|:
1. Let <var>scroller</var> be |active|.
1. Let <var>targets</var> be the set of the [=scroll target=] elements whose nearest ancestor [=scroll container=] is |scroller|
and the [=scroll container=] elements which contain [=scroll target=] elements targeted by the [=scroll marker group=] whose nearest ancestor [=scroll container=] is |scroller|.
1. Let <var>primary</var> be the primary scrolling axis, assumed to be the block direction of the container's writing-mode.
1. Let <var>secondary</var> be the scrolling axis perpendicular to primary.
1. Let <var>position</var> be the 'eventual scroll position' considering ongoing scrolling operations.
1. For each <var>axis</var> of |primary|, followed by |secondary|:
1. Let <var>scrollport size</var> be the client size of |scroller| in the dimension |axis|.
1. For each |target| in |targets|, <a>determine the scroll-into-view position</a> of |target| in |axis|, storing this as the associated |target position| of |target|.
1. Let |selected position| be the largest |target position|
where |target position| is equal to or before |position| in the |axis|,
or whose nearest smaller |target position| < |position| - |scrollport size| / 2 and whose |target position| < |position| + |scrollport size| / 2.

1. : If there is no such position,
::
Set the |selected position| to the first one.

1. Let |active| be the all of the |targets| whose associated |target position| is |selected position|.
1. Let |active| be the first item in |active| if it has more than one potential target.
and the [=scroll container=] elements which contain [=scroll target=] elements targeted by the [=scroll marker group=] whose nearest ancestor [=scroll container=] is |scroller|.
1. : If |scroller| has a non-null [=current scroll target=]
::
Let active be the first item in |targets| encountered by a reverse tree order walk starting from the [=current scroll target=],
or the first item in tree order in |targets| if no target is found in the previous walk.

: Otherwise,
::
1. Let <var>primary</var> be the primary scrolling axis, assumed to be the block direction of the container's writing-mode.
1. Let <var>secondary</var> be the scrolling axis perpendicular to primary.
1. Let <var>position</var> be the 'eventual scroll position' considering ongoing scrolling operations.
1. For each <var>axis</var> of |primary|, followed by |secondary|:
1. Let <var>scrollport size</var> be the client size of |scroller| in the dimension |axis|.
1. For each |target| in |targets|, <a>determine the scroll-into-view position</a> of |target| in |axis|, storing this as the associated |target position| of |target|.
1. Let |selected position| be the largest |target position|
where |target position| is equal to or before |position| in the |axis|,
or whose nearest smaller |target position| < |position| - |scrollport size| / 2 and whose |target position| < |position| + |scrollport size| / 2.

1. : If there is no such position,
::
Set the |selected position| to the first one.

1. Let |active| be the all of the |targets| whose associated |target position| is |selected position|.
1. Let |active| be the first item in |active| if it has more than one potential target.

1. Let |selected marker| be the [=scroll marker=] associated with |active|.
If multiple [=scroll marker=] elements are associated with |active|,
Expand Down
2 changes: 1 addition & 1 deletion css-scroll-anchoring-1/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ following criteria:
* |C| is not in an <a>excluded subtree</a>
* None of the ancestors of |C| up to |S| are in an <a>excluded subtree</a>

Some elements are considered to be <dfn
Some elements are considered to be <dfn export
id="anchor-priority-candidates">priority candidates</dfn> for anchor selection:
1. The [=DOM anchor=] of the [=focused area of the document=], if such an anchor
is text editable ([=editable=], [=editing host=], [=mutable=] <{textarea}>, or
Expand Down

0 comments on commit ccebfb3

Please sign in to comment.