概要 / Overview
Programmatic Scroll Promisesを使うと、JavaScriptでスクロールの完了をPromiseとして待てるようになります。スクロール完了後に行いたい処理を実装するときに便利です。
Programmatic Scroll Promises let JavaScript wait for a programmatic scroll to finish as a Promise. They are useful when implementing behavior that should run after scrolling completes.
対応ブラウザ / Browser support
Programmatic Scroll PromisesはChrome/Edge 150以上で使えます。このデモも対応ブラウザで確認してください。
Programmatic Scroll Promises are available in Chrome and Edge 150 or later. Please check this demo in a supported browser.
動機 / Motivation
これまで、スクロール後に何かを見せたいときはsetTimeout()やscrollendイベントを監視することでスクロールの完了を判定していました。Programmatic
Scroll Promisesがあれば、awaitで明確に完了を待てるようになります。
Previously, code often used setTimeout() or listened
to the scrollend event to determine when scrolling
had ended. Programmatic Scroll Promises make scroll completion a
clear thing to wait for with await.