mirror of
https://github.com/prurigro/hypothetical.git
synced 2024-11-22 07:54:11 -05:00
Add support for between-page anchor links
This commit is contained in:
parent
f8e728e654
commit
b0ac2d651e
1 changed files with 13 additions and 5 deletions
18
resources/assets/js/app-vue.js
vendored
18
resources/assets/js/app-vue.js
vendored
|
@ -33,11 +33,22 @@ const router = new VueRouter({
|
|||
mode: "history",
|
||||
linkActiveClass: "active",
|
||||
root: "/",
|
||||
|
||||
routes: [
|
||||
{ path: "/", component: HomePage },
|
||||
{ path: "/contact", component: ContactPage },
|
||||
{ path: "/*", component: Error404Page }
|
||||
]
|
||||
],
|
||||
|
||||
scrollBehavior(to, from, savedPosition) {
|
||||
if (to.hash) {
|
||||
return {
|
||||
selector: `[id='${to.hash.slice(1)}']`
|
||||
};
|
||||
} else {
|
||||
return { x: 0, y: 0 };
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Create a vuex store instance
|
||||
|
@ -89,10 +100,7 @@ router.beforeEach((to, from, next) => {
|
|||
// Fade the page out and scroll when moving from one page to another
|
||||
TweenMax.to("#router-view", 0.25, {
|
||||
opacity: 0,
|
||||
onComplete: () => {
|
||||
$("html, body").scrollTop(0);
|
||||
next();
|
||||
}
|
||||
onComplete: next
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue