Skip to content

Commit

Permalink
[css-overflow-5] Allow scroll to target unreachable scroll marker tar…
Browse files Browse the repository at this point in the history
…gets (#11318)

This adds to the non-normative suggested algorithm for selecting the active scroll marker
the proposed compromise in #11165 to ensure that scrolling from start to end scrolls
through all of the markers in that scroller.
  • Loading branch information
flackr authored Dec 5, 2024
1 parent ddcea6d commit 11416b9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions css-overflow-5/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,18 @@ Selecting The Active Scroll Marker: the '':target-current'' pseudo-class</h4>
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 <var>scroll size</var> be the length of the <a>scrollable overflow area</a> of the |scroller| in the dimension |axis|.
1. Let <var>scroll range</var> be <code>|scroll size| - |scrollport size|</code>.
1. If |scroll range| is greater than 0, redistribute unreachable target positions:
1. Let <var>distribute range</var> be <code>min(1/8 * |scrollport size|, |scroll range| / 2)</code>.
1. Let <var>before targets</var> be all |targets| whose associated |target position| is less than <code>|distribute range|</code>.
1. Let <var>minimum position</var> be the minimum |target position| of |before targets|.
1. Update the associated |target position| of each target in |before targets| to
<code>(|target position| - |minimum position|) / (|distribute range| - |minimum position|) * |distribute range|</code>.
1. Let <var>after targets</var> be all |targets| whose associated |target position| is greater than <code>|scroll range| - |distribute range|</code>.
1. Let <var>maximum position</var> be the maximum |target position| of |after targets|.
1. Update the associated |target position| of each target in |after targets| to
<code>(|target position| - (|scroll range| - |distribute range|)) / (|maximum position| - (|scroll range| - |distribute range|)) * |distribute range| + (|scroll range| - |distribute range|)</code>.
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.
Expand Down

0 comments on commit 11416b9

Please sign in to comment.