Refactor
This commit is contained in:
parent
1b7a601d27
commit
0e29e864c8
2 changed files with 7 additions and 4 deletions
|
@ -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();
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue