Re: [csswg-drafts] [css-scroll-snap-2] How should competing scroll-start-targets be resolved? (#10774)

To address the use cases and resolve this issue as well as #8832, I propose the following:

1. scroll-start-target does not have per-axis values, i.e. no change to [the spec](https://drafts.csswg.org/css-scroll-snap-2/#scroll-start-target-propdef) as it is currently written.
2. When multiple elements are requested to be scroll start targets, determine the scroll position by scrolling to each one in reverse-dom order.
3. Define `scroll-align`, a generalized version of `scroll-snap-align` that works outside of snap containers and possibly in snap containers without establishing a snap point. This former is [currently a MAY in the spec](https://drafts.csswg.org/css-scroll-snap-1/#choosing):
   > If a page is navigated to a fragment that defines a target element (e.g. one that would be matched by [:target](https://drafts.csswg.org/selectors-4/#target-pseudo), or the target of [scrollIntoView()](https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview)) ... the user agent must [snap](https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap) to one of that element’s snap positions if its nearest [scroll container](https://drafts.csswg.org/css-overflow-3/#scroll-container) is a [scroll snap container](https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-container). The user agent **may** also do this even when the scroll container has [scroll-snap-type: none](https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-snap-type).

   This property should also accept `nearest` values to allow specifying all of the [ScrollLogicalPosition](https://drafts.csswg.org/cssom-view/#enumdef-scrolllogicalposition) values of the [scrollIntoView](https://drafts.csswg.org/cssom-view/#dom-element-scrollintoview) API. It may make sense for scroll snapping to support `nearest` as well to support making items that snap such that they're not partially in view but don't have a particular affinity for aligning only on one side of the scrollport.

The combination of `nearest` values in point 3 and attempting to scroll to multiple items in point 2 would provide a reasonable best-effort attempt to scroll all of the requested items into view while still ensuring that the first one (the current specified behavior) is in view at the end.

-- 
GitHub Notification of comment by flackr
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10774#issuecomment-2327163728 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 3 September 2024 18:29:37 UTC