Adding Custom Timing to Existing Scroll APIs
I wonder if the CSSOM has intentionally limited ScrollBehaviour
to only “smooth” and “instant” so that user-agent can match the platform conventions in case of “smooth”. There is a hint of that in the spec but @zcorpan is the current editor and can shed some light there.
The proposed change suggests adding a easing function but not a duration. This feels incomplete to me in particular if the user agent decides to scroll with duration = 0 then the easing function becomes irrelevant! This would be a lot more powerful and flexible tool for scroll animations if it did support duration (and even delay) too. At which point, we probably want to have something that is actually part of Web Animation and not tacked onto the CSSOM scroll APIs.
Also I feel that a user-specified timing function makes sense only for a single element scroll operations but it may be inappropriate for ‘scrollIntoView’ case where multiple elements may be scrolled (potentially in parallel).
Returning a Promise
+1 for returning a promise. Although it should be possible to polyfill that using ‘scroll’ event but there are a few corner cases which need to be covered (e.g., reaching to boundaries, scroll being interrupted by use input, etc.) which can make it tricky. This feels like a good extension.
Scroll Animation
I agree that a way to animate scroll positions without jank is missing from the platform. We (in Chrome) certainly are thinking about introducing new primitives for high performance animations which do include scroll position. This does not preclude adding other declarative options where it makes sense.