Skip to content

Scroll snap #14

Closed
Closed

Description

@flackr

Description
css-scroll-snap allows creating popular UX paradigms for paged or itemized content, and is essential for taking advantage of the browser's accelerated scrolling mechanisms and not having to reimplement fling physics to make these experiences as smooth and seamless as possible.

Specification
https://drafts.csswg.org/css-scroll-snap/

Tests
Links to web-platform-tests (on https://wpt.fyi) for the feature:

  • Existing tests which demonstrate RTL issues or significant feature deltas
  • Tests to be written
    • Arrow keys should smooth scroll to next snap target
    • Mouse wheel click should immediately scroll to next target
    • When snap area is larger than viewport it should snap to nearest edge (currently jumps to initial snap position), see related csswg issue.

Rationale
Major UX experiences (e.g. carousels, paginated content, etc) are enabled by this feature but lack of polish prevents widespread use. While we tackled and greatly improved the interop in 2021, there are still a few significant gaps. The 2021 scroll survey confirms carousels are important but not yet easy to manage.

Activity

  1. mrobinson commented on Nov 12, 2021

    @mrobinson

    The existing tests here might be a bit misleading, because a lot of issues are fixed in upstream WebKit already. You can see the delta is a bit smaller if you add the experimental version of WebKitGTK to the list of browsers.

  2. flackr commented on Nov 25, 2021

    @flackr
    Author

    @kevers-google is adding the extra few tests.

  3. added
    accepted
    on Dec 14, 2021
  4. foolip commented on Jan 10, 2022

    @foolip
    Member

    A proposed list of tests has been labeled with interop-2022-scrolling. It would be great if someone from each browser engine team can look over this list and comment if there are any issues.

  5. flackr commented on Jan 18, 2022

    @flackr
    Author

    Looks like we're missing css/css-scroll-snap/input/mouse-wheel.html which is one of the newly added tests. Note that in adding these tests we discovered some issues with the test driver event injection, see crbug.com/1285411

  6. foolip commented on Jan 20, 2022

    @foolip
    Member

    A bunch of scrolling tests came up in my analysis in #48. It spans this issue and #21, but I'll past the whole comment since the root cause seems shared across the two in one case:

    There are 3 tests that use new test_driver.Actions().scroll(...) and either ERROR or TIMEOUT in Firefox/Safari:

    https://bugzil.la/1746601 is the Gecko bug about this testdriver API. The harness errors can probably be fixed with the proper t.step_func wrapping or similar.

    /css/css-scroll-snap/input/keyboard.html is TIMEOUT in Firefox and Safari, but the first test runs and fails in Firefox. I don't think this is due to a missing testdriver.js API, but it needs investigation.

    /css/cssom-view/scroll-behavior-smooth.html is ERROR in Chrome and TIMEOUT in Safari. Needs investigation.

  7. flackr commented on Mar 3, 2022

    @flackr
    Author

    @kevers-google, could you look into some of these failures?

  8. kevers-google commented on Mar 3, 2022

    @kevers-google

    Will do

  9. kevers-google commented on Mar 14, 2022

    @kevers-google

    Started looking at the tests involving new test_driver.Actions().scroll(...) . Wheel scrolls do not appear to be supported in test_driver on Firefox or Safari.

    Based on https://web-platform-tests.org/writing-tests/testdriver.html#test_driver.action_sequence, Actions.send() should reject the
    promise if any of the actions fail, so the following example should pass or fail based on whether a wheel scroll was successfully dispatched:

    promise_test(t => {
    return new test_driver.Actions().scroll(200, 500, 0, -200).send();
    }, 'Simple test');

    This minified test is triggering an ERROR instead of a Fail on Firefox (don't have a Mac for testing on Safari). Thus, I don't believe that a test.step will address the harness error. Having said that, overscroll-behavior.html is mixing test.step with promise chains and would likely benefit from being changed to a series of promise tests: one for each of the 4 conditions being tested.

    Will review the other tests shortly.

  10. karlcow commented on Mar 14, 2022

    @karlcow

    Started looking at the tests involving new test_driver.Actions().scroll(...) . Wheel scrolls do not appear to be supported in test_driver on Firefox or Safari.

    For Firefox, there's a in-progress patch from @jgraham
    https://phabricator.services.mozilla.com/D139123

  11. kevers-google commented on Mar 15, 2022

    @kevers-google

    Keyboard.html is Timing out if not seeing the expected scroll in response to a keypress. Since the first test works, it would suggest that Firefox supports test_driver.send_keys(). If 'arrowup' in the second test is replaced with 'pageup' then we reach the desired snap point. If waitForScrollEnd(target_position) is replaced with waitForAnimationEnd(get_position_callback) then we see that the page doesn't switch snap points in response to arrow up. Though waitForAnimationEnd would change a Timeout to a Fail, it was the disadvantage of being potentially flaky since it depends on waiting for nothing to happen for a number of animation frames to infer that scrolling has stopped. Ultimately waitForScrollEnd results in faster test execution when everything is scrolling properly since we don't have the extra rAF wait time.

  12. kevers-google commented on Mar 15, 2022

    @kevers-google

    /css/cssom-view/scroll-behavior-smooth.html seems to be passing everywhere. Perhaps the linked bugs are stale. Perhaps the test was written before the feature was fully supported across browsers.

  13. mrobinson commented on Mar 15, 2022

    @mrobinson

    Keyboard.html is Timing out if not seeing the expected scroll in response to a keypress. Since the first test works, it would suggest that Firefox supports test_driver.send_keys(). If 'arrowup' in the second test is replaced with 'pageup' then we reach the desired snap point.

    There are a couple more issues with this particular test as well:

  14. foolip commented on Mar 18, 2022

    @foolip
    Member

    Thanks for digging into the failures, @kevers-google and @mrobinson! For the tests that error instead of fail, does someone have the time to try fixing those to properly fail instead?

  15. added
    focus-area-proposal
    and removed on Sep 16, 2022
  16. added this to the Interop 2022 milestone on Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedfocus-area-proposal

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions