From 149de5b17bb48e16f2f9e821e3e0ec584ec76867 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 1 Feb 2020 09:59:55 +0900 Subject: [PATCH] Improve navigation --- src/client/init.ts | 2 ++ src/client/router.ts | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/client/init.ts b/src/client/init.ts index ef2cf9a49a..6cd7734fd6 100644 --- a/src/client/init.ts +++ b/src/client/init.ts @@ -54,6 +54,8 @@ if (localStorage.getItem('kyoppie') === 'yuppie') { location.reload(true); } +window.history.scrollRestoration = 'manual'; + if (localStorage.getItem('theme') == null) { applyTheme(lightTheme); } diff --git a/src/client/router.ts b/src/client/router.ts index 1f0dac3a41..816f72595a 100644 --- a/src/client/router.ts +++ b/src/client/router.ts @@ -52,10 +52,13 @@ export const router = new VueRouter({ ], // なんかバギー scrollBehavior(to, from, savedPosition) { - if (savedPosition) { - return savedPosition; - } else { - return { x: 0, y: 0 }; - } + setTimeout(() => { + if (savedPosition) { + window.scroll({ top: savedPosition.y, behavior: 'instant' }); + } else { + window.scroll({ top: 0, behavior: 'instant' }); + } + }, 1000); + return; } });