mirror of
https://github.com/asimonson1125/asimonson1125.github.io.git
synced 2026-02-25 05:09:49 -06:00
separate hashchange, goto events
This commit is contained in:
@@ -19,8 +19,11 @@ async function goto(location, { push = true } = {}) {
|
|||||||
mode: "cors",
|
mode: "cors",
|
||||||
});
|
});
|
||||||
const response = await a.json();
|
const response = await a.json();
|
||||||
if (!location.includes("#")) {
|
if (!window.location.href.includes("#")) {
|
||||||
window.scrollTo({top: 0, left: 0, behavior:"instant"});
|
window.scrollTo({top: 0, left: 0, behavior:"instant"});
|
||||||
|
} else {
|
||||||
|
eid = decodeURIComponent(window.location.hash.substring(1))
|
||||||
|
document.getElementById(eid).scrollIntoView()
|
||||||
}
|
}
|
||||||
const metadata = response[0];
|
const metadata = response[0];
|
||||||
const content = response[1];
|
const content = response[1];
|
||||||
@@ -37,6 +40,6 @@ async function goto(location, { push = true } = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function backButton() {
|
function backButton() {
|
||||||
const location = window.location.href;
|
const location = window.location.pathname;
|
||||||
goto(location.substring(1), { push: false }); // remove slash, goto already does that
|
goto(location.substring(1), { push: false }); // remove slash, goto already does that
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user