We (rbyers@ and I) are considering a slight re-scoping of scroll customization, which will clarify its role in the web platform, minimize its API surface, and simplify its implementation.
In particular, we've come to believe that programmatic scrolls should not be customizable using scroll customization. The role of scroll customization is to map a user’s intent to scroll into concrete requests to scroll specific scrollable areas[1]. As programmatic scroll requests aren't communicating user intent, but are already concrete requests to scroll specific scrollable areas, scroll customization should not apply to them. This is reflected in the updated
scrolling architecture diagram. Anecdotally, this aligns well with IE’s implementation of snap points, which customizes scrolling via user input, but doesn't effect programmatic scrolling.
Many scrolling related APIs cause a scroll to an absolute location, such as
element.scrollIntoView(). It isn’t adequate to map directly from absolute locations to deltas, since scroll customization might modify the deltas, resulting in a call to element.scrollIntoView not scrolling the element into view. Scrolling by a delta and scrolling to an absolute location are distinct operations, which must be handled differently. In order to enable scroll customization to customize scrolls to absolute locations, we’d need to add additional API surface. If we choose not to let scroll customization apply to programmatic scrolling, a developer can customize the behavior of programmatic scrolling apis by overriding the programmatic scrolling methods (which could call into scroll customization logic if similar behavior is required).
This results in three categories of scrolling related effects:
- Scroll response:
- Opting into synchronous scrolling and adding a scroll event listener enables responding to programmatic and user input triggered scrolls.
- Scroll application customization:
- Overriding the applyScroll[2] method enables responding to and possibly modifying how a user’s intent to scroll is applied to an element.
- Scroll distribution customization
- Overriding the distributeScroll method enables changing how a user’s intent to scroll is distributed among the elements in the scroll chain.
Any thoughts on this change in scope? If there are no objections, I'll start performing some related renaming shortly.
[1] Some user input results in concrete requests to scroll specific scrollable areas to specific locations (the HOME and END keys). These inputs should not trigger scroll customization.
[2] We may rename this to indicate that it doesn't deal with programmatic scrolls. Any ideas? I’m partial to applyScrollIntent.