asr-scroll-position
Manually update the browser's scroll position when using pushState routing with abstract-state-router
Last updated 3 years ago by tehshrike .
WTFPL · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install asr-scroll-position 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.1.0                                ...           latest (3 years ago)

3 Versions

  • 1.1.0                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 2
Last Day 1
Last Week 0
Last Month 3
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |