Skip to content

Commit 2d97a0a

Browse files
authored
[css-overflow-5] Treat the last scroll target as active (#11320)
When a targeted scroll is performed, use that target to determine the active scroll marker. Fixes #10738.
1 parent 11416b9 commit 2d97a0a

File tree

1 file changed

+57
-28
lines changed

1 file changed

+57
-28
lines changed

css-overflow-5/Overview.bs

+57-28
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,28 @@ its content will be integrated into this specification,
154154
which will then replace it.
155155
Until then, this specification only contains additions and extensions to level 4.
156156

157+
<h2 id="overflow-concepts">
158+
Overflow Concepts and Terminology</h2>
159+
160+
Issue: Copy [[css-overflow-3#overflow-concepts|Level 3 content]] when final.
161+
162+
<h3 id="scrolling">Scrolling overflow</h3>
163+
164+
The following is added to the concepts in scrolling overflow:
165+
166+
Every [=scroll container=] maintains a <dfn export>current scroll target</dfn>.
167+
It is initially <code>null</code>,
168+
and is reset to <code>null</code> after any scrolling operations in that [=scroll container=]
169+
initiated by the user,
170+
or any script initiated operations that do not have a target,
171+
or when the target is removed from the document.
172+
Scrolling operations in the [=scroll container=] with a target Element or PseudoElement,
173+
set the [=current scroll target=] to that target Element or PseudoElement.
174+
175+
Issue: Setting the current scroll target should be defined in how to <a>scroll a target into view</a>.
176+
177+
Issue: Use the current scroll target as an <a>anchor priority candidate</a> for scroll anchoring.
178+
157179
<h2 id="scroll-navigation">
158180
Scroll navigation controls</h2>
159181

@@ -304,34 +326,41 @@ Selecting The Active Scroll Marker: the '':target-current'' pseudo-class</h4>
304326
1. Let <var>scroller</var> be |active|.
305327
1. Let <var>targets</var> be the set of the [=scroll target=] elements whose nearest ancestor [=scroll container=] is |scroller|
306328
and the [=scroll container=] elements which contain [=scroll target=] elements targeted by the [=scroll marker group=] whose nearest ancestor [=scroll container=] is |scroller|.
307-
1. Let <var>primary</var> be the primary scrolling axis, assumed to be the block direction of the container's writing-mode.
308-
1. Let <var>secondary</var> be the scrolling axis perpendicular to primary.
309-
1. Let <var>position</var> be the 'eventual scroll position' considering ongoing scrolling operations.
310-
1. For each <var>axis</var> of |primary|, followed by |secondary|:
311-
1. Let <var>scrollport size</var> be the client size of |scroller| in the dimension |axis|.
312-
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|.
313-
1. Let <var>scroll size</var> be the length of the <a>scrollable overflow area</a> of the |scroller| in the dimension |axis|.
314-
1. Let <var>scroll range</var> be <code>|scroll size| - |scrollport size|</code>.
315-
1. If |scroll range| is greater than 0, redistribute unreachable target positions:
316-
1. Let <var>distribute range</var> be <code>min(1/8 * |scrollport size|, |scroll range| / 2)</code>.
317-
1. Let <var>before targets</var> be all |targets| whose associated |target position| is less than <code>|distribute range|</code>.
318-
1. Let <var>minimum position</var> be the minimum |target position| of |before targets|.
319-
1. Update the associated |target position| of each target in |before targets| to
320-
<code>(|target position| - |minimum position|) / (|distribute range| - |minimum position|) * |distribute range|</code>.
321-
1. Let <var>after targets</var> be all |targets| whose associated |target position| is greater than <code>|scroll range| - |distribute range|</code>.
322-
1. Let <var>maximum position</var> be the maximum |target position| of |after targets|.
323-
1. Update the associated |target position| of each target in |after targets| to
324-
<code>(|target position| - (|scroll range| - |distribute range|)) / (|maximum position| - (|scroll range| - |distribute range|)) * |distribute range| + (|scroll range| - |distribute range|)</code>.
325-
1. Let |selected position| be the largest |target position|
326-
where |target position| is equal to or before |position| in the |axis|,
327-
or whose nearest smaller |target position| < |position| - |scrollport size| / 2 and whose |target position| < |position| + |scrollport size| / 2.
328-
329-
1. : If there is no such position,
330-
::
331-
Set the |selected position| to the first one.
332-
333-
1. Let |active| be the all of the |targets| whose associated |target position| is |selected position|.
334-
1. Let |active| be the first item in |active| if it has more than one potential target.
329+
1. : If |scroller| has a non-null [=current scroll target=]
330+
::
331+
Let active be the first item in |targets| encountered by a reverse tree order walk starting from the [=current scroll target=],
332+
or the first item in tree order in |targets| if no target is found in the previous walk.
333+
334+
: Otherwise,
335+
::
336+
337+
1. Let <var>primary</var> be the primary scrolling axis, assumed to be the block direction of the container's writing-mode.
338+
1. Let <var>secondary</var> be the scrolling axis perpendicular to primary.
339+
1. Let <var>position</var> be the 'eventual scroll position' considering ongoing scrolling operations.
340+
1. For each <var>axis</var> of |primary|, followed by |secondary|:
341+
1. Let <var>scrollport size</var> be the client size of |scroller| in the dimension |axis|.
342+
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|.
343+
1. Let <var>scroll size</var> be the length of the <a>scrollable overflow area</a> of the |scroller| in the dimension |axis|.
344+
1. Let <var>scroll range</var> be <code>|scroll size| - |scrollport size|</code>.
345+
1. If |scroll range| is greater than 0, redistribute unreachable target positions:
346+
1. Let <var>distribute range</var> be <code>min(1/8 * |scrollport size|, |scroll range| / 2)</code>.
347+
1. Let <var>before targets</var> be all |targets| whose associated |target position| is less than <code>|distribute range|</code>.
348+
1. Let <var>minimum position</var> be the minimum |target position| of |before targets|.
349+
1. Update the associated |target position| of each target in |before targets| to
350+
<code>(|target position| - |minimum position|) / (|distribute range| - |minimum position|) * |distribute range|</code>.
351+
1. Let <var>after targets</var> be all |targets| whose associated |target position| is greater than <code>|scroll range| - |distribute range|</code>.
352+
1. Let <var>maximum position</var> be the maximum |target position| of |after targets|.
353+
1. Update the associated |target position| of each target in |after targets| to
354+
<code>(|target position| - (|scroll range| - |distribute range|)) / (|maximum position| - (|scroll range| - |distribute range|)) * |distribute range| + (|scroll range| - |distribute range|)</code>.
355+
1. Let |selected position| be the largest |target position|
356+
where |target position| is equal to or before |position| in the |axis|,
357+
or whose nearest smaller |target position| < |position| - |scrollport size| / 2 and whose |target position| < |position| + |scrollport size| / 2.
358+
1. : If there is no such position,
359+
::
360+
Set the |selected position| to the first one.
361+
362+
1. Let |active| be the all of the |targets| whose associated |target position| is |selected position|.
363+
1. Let |active| be the first item in |active| if it has more than one potential target.
335364

336365
1. Let |selected marker| be the [=scroll marker=] associated with |active|.
337366
If multiple [=scroll marker=] elements are associated with |active|,

0 commit comments

Comments
 (0)