Description
The cssom-view-1 spec currently specifies both scrollTo and scrollBy as if they both invoke the scroll method with the left and top set accordingly. However, I think that we should differentiate these APIs as relative directional scrolls and absolute scrolls as far as they affect several other APIs. The legacy scrollLeft
and scrollTop
should probably be treated as absolute scrolls as that is usually what they are used for.
Absolute scrolls:
- If interrupting an ongoing scroll, use the specified offset exactly.
- Are treated as intended end position scrolls by scroll snap: https://www.w3.org/TR/css-scroll-snap-1/#scroll-types
- Don't set the last scroll direction for state queries [css-ui][selectors][mediaqueries] Expose current scrolling direction #6400
Relative / directional scrolls:
- If interrupting an ongoing scroll, add their relative offset to the interrupted scroll position. E.g.
scrollBy(0, 10)
scroll always scroll 10px down rather than potentially scrolling up if there was an ongoing fling scroll. - Are treated as intended direction and end position by scroll snap: https://www.w3.org/TR/css-scroll-snap-1/#scroll-types
- Change the last scroll direction for state queries [css-ui][selectors][mediaqueries] Expose current scrolling direction #6400
Proposed resolution:
Define a consistent distinction between absolute scrolls and relative scrolls that can be implemented and shared across these affected specs.
Absolute scrolls: scrollTo, scrollLeft, scrollTop, anchor fragment scrolls, scroll anchoring, find in page scrolls, scroll thumb dragging?
Relative scrolls: scrollBy, arrow key, page up/down, spacebar, home/end?, scrollbar track clicks, scrollbar buttons
Any other ways of scrolling we need to categorize?