@af-utils/scrollend-polyfill

This package adds the scrollend event to browsers that do not expose it natively. It supports addEventListener/removeEventListener; assigning onscrollend is outside the polyfill boundary.

Installation

npm install @af-utils/scrollend-polyfill

Usage

import "@af-utils/scrollend-polyfill";

Import it once at the application entry point. The module does nothing in Node or when the browser already supports scrollend.

When the event fires

The polyfill dispatches scrollend after scrolling has been quiet for a short period and no tracked touch gesture remains active. Touch cancellation and aborted, captured, duplicate, or one-time listeners follow the normal event listener lifecycle.

Trackpad limitation

Browsers expose desktop trackpad scrolling as a stream of wheel and scroll events, without a reliable event for fingers remaining in contact with or being released from the trackpad. The polyfill therefore uses the quiet period for trackpad input and may dispatch scrollend while the user’s fingers are still resting on the trackpad. Native scrollend, when available, remains responsible for the complete browser-managed gesture and momentum lifecycle.

See the runnable React example and bundle-size report.