1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-11-24 23:26:17 +09:00
This commit is contained in:
syuilo 2020-02-06 18:25:25 +09:00
parent 1b7a601d27
commit 0e29e864c8
2 changed files with 7 additions and 4 deletions

View File

@ -76,7 +76,7 @@
<div class="contents">
<main ref="main">
<div class="content">
<transition name="page" mode="out-in">
<transition name="page" mode="out-in" @enter="onTransition">
<keep-alive :include="['index']">
<router-view></router-view>
</keep-alive>
@ -258,6 +258,10 @@ export default Vue.extend({
if (this.canBack) window.history.back();
},
onTransition() {
if (window._scroll) window._scroll();
},
post() {
this.$root.post();
},

View File

@ -56,13 +56,12 @@ export const router = new VueRouter({
// 通常の使い方をすると scroll メソッドの behavior を設定できないため、自前で window.scroll するようにする
// setTimeout しないと、アニメーション(トランジション)の関係でうまく動かない
scrollBehavior(to, from, savedPosition) {
setTimeout(() => {
window._scroll = () => { // さらにHacky
if (savedPosition) {
window.scroll({ top: savedPosition.y, behavior: 'instant' });
} else {
window.scroll({ top: 0, behavior: 'instant' });
}
}, 600);
return;
};
}
});