Package Exports
- asr-scroll-position
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (asr-scroll-position) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Uses the browser history API to keep track of scroll position manually, since it turns out most browsers scroll position remembering doesn't work well if you render the page on the tick after a pushState
happens.
- On scroll/resize, update the current position in state
- On old state, wait for stateChangeEnd, then scroll to the position from state
- On new state, wait for stateChangeEnd, then scroll to the anchor if it exists, else scroll to top
Usage
const watchScrollPosition = require('asr-scroll-position')
watchScrollPosition(stateRouter)