router.middleware.scrollPosition
Add support for:
- restoring scroll position on back-button navigation
- scrolling to anchors (#hash), or the top on forward navigation
Usage
import {
Router,
createScrollPositionMiddleware
} from '@profiscience/knockout-contrib'
Router.use(
createScrollPositionMiddleware({
// optionally supply a custom scroll function (add smooth scrolling, use Velocity, etc.)
scrollTo(x, y) { ... }
})
)