Browse Source

Scroll up on hash change

mj-deploy
Standa Lukeš 4 years ago
parent
commit
e4d27070b9
  1. 2
      frontend/rollup.config.js
  2. 5
      frontend/src/App.svelte
  3. 5
      frontend/src/TaskPanel.svelte

2
frontend/rollup.config.js

@ -53,7 +53,7 @@ function plugins(editor) {
inlineSources: !halfProduction inlineSources: !halfProduction
}), }),
replace({ replace({
"allowEditor": false, "allowEditor": editor,
}), }),
// In dev mode, call `npm run start` once // In dev mode, call `npm run start` once

5
frontend/src/App.svelte

@ -11,6 +11,11 @@
let hash = window.location.hash.substr(1); let hash = window.location.hash.substr(1);
window.onhashchange = () => { window.onhashchange = () => {
hash = window.location.hash.substr(1); hash = window.location.hash.substr(1);
window.setTimeout(() => window.scrollTo({
top: 0,
left: 0,
behavior: 'smooth'
}), 50)
}; };
$: selectedTaskId = (/^task\/([^\/]*)/.exec(hash) || [null, null])[1]; $: selectedTaskId = (/^task\/([^\/]*)/.exec(hash) || [null, null])[1];
</script> </script>

5
frontend/src/TaskPanel.svelte

@ -26,11 +26,6 @@ import { taskStatuses } from "./task-status-cache";
function close() { function close() {
heightClass = "closed" heightClass = "closed"
window.setTimeout(() => window.scrollTo({
top: 0,
left: 0,
behavior: 'smooth'
}), 100)
location.hash = "" location.hash = ""
} }