From fce4efe073ce865210f17ce9feb8e00788b4eae4 Mon Sep 17 00:00:00 2001 From: David Awogbemila Date: Fri, 20 Sep 2024 11:57:58 -0400 Subject: [PATCH] Resolve multiple scroll-start-targets by reverse DOM order --- css-scroll-snap-2/Overview.bs | 54 +++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/css-scroll-snap-2/Overview.bs b/css-scroll-snap-2/Overview.bs index 0b004832b236..f87c79461207 100644 --- a/css-scroll-snap-2/Overview.bs +++ b/css-scroll-snap-2/Overview.bs @@ -137,31 +137,32 @@ The 'scroll-start-target' property {#scroll-start-target}

Initial scroll target

- The [=initial scroll target=] of a scroll container |scrollcontainer| + An [=initial scroll target=] of a scroll container |scrollcontainer| is an element or pseudo-element whose 'scroll-start-target'property is non-''scroll-start-target/none'' - and whose nearest scroll container is |scrollcontainer|. - When multiple such elements or pseudo-elements exist, - user-agents should select the one - which comes first in [=tree order=]. - When no such element or pseudo-element exists, - |scrollcontainer|’s initial scroll target is null. - -
- If the initial scroll target of a scroll container is not null, - it should be used to determine the initial scroll position of |scrollcontainer| - by running the following steps: - - 1. Let |target| be the initial scroll target for |scrollcontainer|. - 1. Let |position| be the result of running the steps to - determine the scroll-into-view position of |target| - with behavior set to "auto", - block set to "start", - inline set to "nearest", - and scrolling box set to |scrollcontainer|. - 1. Set |scrollcontainer|'s initial scroll position to |position|. -
- + and whose nearest scroll container is |scrollcontainer|. |scrollcontainer| + may have more than one initial scroll target. + +
Determining initial scroll position from + scroll-start-target
+ To determine the initial scroll position of a scroll container |scrollcontainer| using its + initial scroll targets, user-agents should run the following steps: + + 1. Let initial-scroll-target-list be a list of the initial scroll targets of |scrollcontainer|, + sorted in reverse tree order. + 1. For |target| in initial-scroll-target-list: + 1. Let |position| be the result of running the steps to + determine the scroll-into-view position of |target| + with behavior set to "auto", + block set to "start", + inline set to "nearest", + and scrolling box set to |scrollcontainer|. + 1. Set |scrollcontainer|'s initial scroll position to |position|. + +NOTE: Sorting initial-scroll-target-list in reverse +tree order +is intended to prioritize having the first initial scroll target in tree order +scrolled into view.

scroll-start-target Property Definition

@@ -199,10 +200,9 @@ Post-first layout arrivals a scroll container's [=initial scroll target=] might arrive after that scroll container has been laid out. If this happens, - user agents should still scroll to the [=initial scroll target=] - unless the user agent has reason to believe - the user is no longer interested - in scrolling to the initial scroll position. + user agents should still scroll to the initial scroll position + determined by 'scroll-start-target' unless the user agent has reason to believe + the user is no longer interested in scrolling to the initial scroll position.