Skip to content

[css-scroll-snap] Consider more specific guidance for scroll-into-view #1707

@fantasai

Description

@fantasai

From a discussion about scrollOptions in whatwg/html#2787 (comment) ...

As for the preferred position of the focused element, the CSS Scroll Snap module already defines various parameters for the preferred scroll positions for viewing an element, and imho it is better to re-use these rather than establish a contradictory and less powerful set of arguments in the .focus() API. The scroll-padding property already specifies that it applies, and probably scroll-snap-margin should as well. The spec currently avoids specifying that focusing operations inherently trigger snapping to the element’s snap position, but it does specify that (even when snapping is off), a #fragmentID-targetted element should snap into position... so if this is desired behavior we can look into defining that behavior as well. In any case, it doesn't seem like this belongs specifically in the JS API, unless for some reason the behavior of an API call needs to differ from that of a user-triggered event.

Possible guidance to consider:

  • Suggesting that scroll-into-view operations consider scroll-snap-margin in addition to scroll-padding
  • Recommending that UAs use the element's snap position if it has one and snapping is on.
  • Allowing UAs to use the suggested snap position, if the element has defined one, even if snapping is off.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions