← Back to release summary

Programmatic scroll promises

Category
JavaScript
Type
Chromium catches up
Status
Proposed (Chrome Proposed)
Intent stage
None

Summary

This feature provides a reliable signal for the completion status of a programmatic smooth-scroll. All scroll methods in Element and Window now return Promise objects that get resolved on scroll completion, and the resolved value indicates whether the scroll was interrupted or not.

Motivation

We have multiple scroll methods available through both Element and Window interfaces. These methods return immediately with the value undefined, which was fine during the early days of the web when scroll was assumed to be instant. This behavior no longer seems adequate from a web developer's perspective today: there is widespread support for smooth-scroll (see browser_compatibility [1] for the CSS property), and it is not easy for the developers to determine when a particular call for a smooth-scroll has completed. This feature makes the programmatic scroll methods return Promise objects that get resolved on scroll completion. The Promise is resolved with an object with a Boolean field indicating whether the scroll was interrupted or not. [1] https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior#browser_compatibility

Standards & signals

Docs: https://github.com/explainers-by-googlers/promisify-scroll

Samples: https://codepen.io/mustaqahmed/full/gbpmNOP

Explainers: https://github.com/explainers-by-googlers/promisify-scroll

View on chromestatus.com