From e4d27070b93769011bb360fe903af65652474c8c Mon Sep 17 00:00:00 2001 From: exyi Date: Sat, 17 Oct 2020 20:18:54 +0000 Subject: [PATCH] Scroll up on hash change --- frontend/rollup.config.js | 2 +- frontend/src/App.svelte | 5 +++++ frontend/src/TaskPanel.svelte | 5 ----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/rollup.config.js b/frontend/rollup.config.js index e73fc21..36f8303 100644 --- a/frontend/rollup.config.js +++ b/frontend/rollup.config.js @@ -53,7 +53,7 @@ function plugins(editor) { inlineSources: !halfProduction }), replace({ - "allowEditor": false, + "allowEditor": editor, }), // In dev mode, call `npm run start` once diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index d14a0ad..8016fd0 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -11,6 +11,11 @@ let hash = window.location.hash.substr(1); window.onhashchange = () => { hash = window.location.hash.substr(1); + window.setTimeout(() => window.scrollTo({ + top: 0, + left: 0, + behavior: 'smooth' + }), 50) }; $: selectedTaskId = (/^task\/([^\/]*)/.exec(hash) || [null, null])[1]; diff --git a/frontend/src/TaskPanel.svelte b/frontend/src/TaskPanel.svelte index ffc02f9..7507267 100644 --- a/frontend/src/TaskPanel.svelte +++ b/frontend/src/TaskPanel.svelte @@ -26,11 +26,6 @@ import { taskStatuses } from "./task-status-cache"; function close() { heightClass = "closed" - window.setTimeout(() => window.scrollTo({ - top: 0, - left: 0, - behavior: 'smooth' - }), 100) location.hash = "" }