mirror of
https://github.com/prurigro/hypothetical.git
synced 2024-11-26 00:51:26 -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",
|
mode: "history",
|
||||||
linkActiveClass: "active",
|
linkActiveClass: "active",
|
||||||
root: "/",
|
root: "/",
|
||||||
|
|
||||||
routes: [
|
routes: [
|
||||||
{ path: "/", component: HomePage },
|
{ path: "/", component: HomePage },
|
||||||
{ path: "/contact", component: ContactPage },
|
{ path: "/contact", component: ContactPage },
|
||||||
{ path: "/*", component: Error404Page }
|
{ 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
|
// 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
|
// Fade the page out and scroll when moving from one page to another
|
||||||
TweenMax.to("#router-view", 0.25, {
|
TweenMax.to("#router-view", 0.25, {
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
onComplete: () => {
|
onComplete: next
|
||||||
$("html, body").scrollTop(0);
|
|
||||||
next();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue