Skip to content

[css-scroll-snap-1] expected behavior when scrolling past a container's last visible element #4111

Description

@justingrant

What's expected behavior when scroll snap is enabled and the user tries to scroll past the last snap position? Example: https://codepen.io/anon/pen/orOmeP. I'm asking because:

  • WebKit (Mac Safari, iOS any) will scroll to the end, leaving nothing visible in the viewport.
  • Blink (desktop Chrome) will refuse to scroll past the last visible element.

Which is correct? Or is this behavior currently unspecified?

FWIW, the current WebKit behavior causes a race condition that breaks current "virtual scrolling" implementations like Facebook's react-window that use JavaScript to JIT add/move absolutely-positioned elements in an otherwise-empty, very long container to simulate scrolling through a long list. Safari will scroll to the end of the content before the virtual-scrolling script has a chance to move elements to the user's new scroll position. Desktop Chrome doesn't have this problem.

If this behavior isn't specified today, then I'd suggest adopting the Chrome behavior as default in the standard. If it is specified, then is there any standardized way for infinite-scroll implementations to get the Chrome behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions