All Projects → fregante → scroll-restoration-polyfill

fregante / scroll-restoration-polyfill

Licence: MIT License
Polyfill for the "History API: Scroll Restoration"

Programming Languages

HTML
75241 projects
javascript
184084 projects - #8 most used programming language

scroll-restoration-polyfill

Prevent the scroll restoration caused by the popstate event or back/forward buttons. Demo

gzipped size Travis build status npm version

Warning: it works in Chrome, Safari, and Firefox 46+, but there's no IE/Edge support yet.

Usage

The polyfill has no API. Once included, just use the official API as described on Chrome Developers:

// Prevent the scroll, always
history.scrollRestoration = 'manual';

// Stop preventing the scroll
history.scrollRestoration = 'auto';

Install

Pick your favorite:

<script src="dist/scroll-restoration-polyfill.browser.js"></script>
npm install --save scroll-restoration-polyfill
require('scroll-restoration-polyfill');
import 'scroll-restoration-polyfill';

Links

Dependencies

Two lightweight dependencies, already included in scroll-restoration-polyfill's scroll-restoration-polyfill's gzipped size

License

MIT © Federico Brigante

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].