Skip to content

Commit 11416b9

Browse files
authored
[css-overflow-5] Allow scroll to target unreachable scroll marker targets (w3c#11318)
This adds to the non-normative suggested algorithm for selecting the active scroll marker the proposed compromise in w3c#11165 to ensure that scrolling from start to end scrolls through all of the markers in that scroller.
1 parent ddcea6d commit 11416b9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

css-overflow-5/Overview.bs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,18 @@ Selecting The Active Scroll Marker: the '':target-current'' pseudo-class</h4>
310310
1. For each <var>axis</var> of |primary|, followed by |secondary|:
311311
1. Let <var>scrollport size</var> be the client size of |scroller| in the dimension |axis|.
312312
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>.
313325
1. Let |selected position| be the largest |target position|
314326
where |target position| is equal to or before |position| in the |axis|,
315327
or whose nearest smaller |target position| < |position| - |scrollport size| / 2 and whose |target position| < |position| + |scrollport size| / 2.

0 commit comments

Comments
 (0)