From 0e29e864c8f2299755323c564ddfb4c9b7f4b492 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 6 Feb 2020 18:25:25 +0900 Subject: [PATCH] Refactor --- src/client/app.vue | 6 +++++- src/client/router.ts | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/client/app.vue b/src/client/app.vue index 4e89aa4351..d515ac02d3 100644 --- a/src/client/app.vue +++ b/src/client/app.vue @@ -76,7 +76,7 @@
- + @@ -258,6 +258,10 @@ export default Vue.extend({ if (this.canBack) window.history.back(); }, + onTransition() { + if (window._scroll) window._scroll(); + }, + post() { this.$root.post(); }, diff --git a/src/client/router.ts b/src/client/router.ts index 5ab4fa0cb6..82451260c3 100644 --- a/src/client/router.ts +++ b/src/client/router.ts @@ -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; + }; } });