Extensible Scrolling
Motivation
We needed this 6 years ago!
Vision
Competing with native requires extensibility
scroll-delay
UIWorker
A healthy web requires that we do both!
Design
Here's exactly what this means.
sort of
scroll-delay
‘scroll-delay’
Value: none | � | [ start-touch || wheel-event || scroll-event ]
Initial: none
Applies to: all elements
Inherited: no
UA style sheet:
html { scroll-delay: start-touch wheel-event }
Bug 347272
UIWorker
See Ian Vollick's talk
(1:15 - Pacific Ocean)
beforescroll
Element.prototype.scroll = function(scrollState) {� var dx, dy;� if (scrollState.deltaY && this.canScrollY) {� if (scrollState.deltaY > 0) {� dy = Math.min(scrollState.deltaY, � this.scrollHeight - this.scrollTop);� } else {� dy = Math.max(scrollState.deltaY, � -this.scrollTop);� }� this.scrollTop += dy;� }� if (scrollState.deltaX && this.canScrollX) { … }� scrollState.consumeDelta(dx, dy);�}
Bug 416862
beforescroll
Element.prototype.distributeScroll = function(scrollState) {� scrollState.popScrollChain().distributeScroll(scrollState);� this.scroll(scrollState);�}
beforescroll
document.scroll = function(scrollState) {� // Handle top controls� scrollState.consumeDelta(0, topControls.scroll(scrollState.deltaY));� if (scrollState.inInertialPhase || scrollState.isEnding)� topControls.snap();�� Element.prototype.scroll(scrollState); // "super" in ES6�� // Handle overscroll� if (scrollState.deltaX || scrollState.deltaY)� overscrollEffect.scroll(scrollState);�}
Demos
Q&A
Discussion: input-dev@chromium.org
beforescroll - obsolete DOM event
Element.prototype.onbeforescroll = function(evt) {� var dx, dy;� if (evt.deltaY && this.scrollsOverflowY) {� if (evt.deltaY > 0) {� dy = Math.min(evt.deltaY, this.scrollHeight - this.scrollTop);� } else {� dy = Math.max(evt.deltaY, -this.scrollTop);� }� this.scrollTop += dy;� }� if (evt.deltaX && this.scrollsOverflowX) { … }� evt.consumeDelta(dx, dy);�}