Adjusted hash routing

This commit is contained in:
Dunemask 2022-12-26 19:49:00 -05:00
parent de6f009905
commit 7c7c83bc43

View file

@ -12,11 +12,11 @@ export function useScrollToLocation() {
hashRef.current = hash; hashRef.current = hash;
scrolledRef.current = false; scrolledRef.current = false;
} }
navigate();
if (scrolledRef.current) return; if (scrolledRef.current) return;
const id = hash.replace("#", ""); const id = hash.replace("#", "");
const element = document.getElementById(id); const element = document.getElementById(id);
if (!element) return; if (!element) return;
navigate();
element.scrollIntoView({ behavior: "smooth", block: "start" }); element.scrollIntoView({ behavior: "smooth", block: "start" });
scrolledRef.current = true; scrolledRef.current = true;
}); });