asr-scroll-position

1.1.0 • Public • Published

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)

License

WTFPL

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    4
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.0
    4
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i asr-scroll-position

Weekly Downloads

4

Version

1.1.0

License

WTFPL

Unpacked Size

4.85 kB

Total Files

4

Last publish

Collaborators

  • tehshrike