Created
August 17, 2018 08:49
-
-
Save andreasvirkus/1c97b36a00b157779caca80238e112aa to your computer and use it in GitHub Desktop.
Vue router middleware which keeps the scroll state of the former page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import VueRouter from 'vue-router' | |
export default new VueRouter({ | |
scrollBehavior(to, from, savedPosition) { | |
if (to.hash) { | |
return { selector: to.hash } | |
} | |
return savedPosition || { x: 0, y: 0 } | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment