Skip to content

Commit

Permalink
frontend: use the load event to set to manual score, jump to hash if …
Browse files Browse the repository at this point in the history
…present
  • Loading branch information
terrablue committed May 19, 2024
1 parent b5c2691 commit 65e3c06
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/frontend/src/client/spa/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const headers = {
Accept: APPLICATION_JSON,
};

history.scrollRestoration = "manual";

const scroll = (x, y) => global.scrollTo(x, y);
const scroll_hash = hash => {
if (hash === "") {
Expand Down Expand Up @@ -93,6 +91,13 @@ const go = async (href, updater, event) => {
};

export default updater => {
global.addEventListener("load", _ => {
history.scrollRestoration = "manual";
if (global.location.hash !== "") {
scroll_hash(global.location.hash);
}
});

global.addEventListener("beforeunload", _ => {
history.scrollRestoration = "auto";
});
Expand Down

0 comments on commit 65e3c06

Please sign in to comment.