mirror of
https://github.com/Ellpeck/ObsidianJustSharePlease.git
synced 2024-11-26 20:28:34 +01:00
don't reload the page when navigating to an anchor
This commit is contained in:
parent
eac391b364
commit
f2d8da4e67
1 changed files with 8 additions and 3 deletions
|
@ -69,7 +69,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let main = $("#main");
|
let main = $("#main");
|
||||||
$(window).on("hashchange", display);
|
$(window).on("hashchange", e => {
|
||||||
|
let oldUrl = e.originalEvent?.oldURL;
|
||||||
|
let oldHash = oldUrl?.lastIndexOf("#");
|
||||||
|
if (oldHash && getId(oldUrl.substring(oldHash)) !== getId())
|
||||||
|
display();
|
||||||
|
});
|
||||||
display();
|
display();
|
||||||
|
|
||||||
function display() {
|
function display() {
|
||||||
|
@ -92,8 +97,8 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
function getId(hash) {
|
||||||
let hash = window.location.hash;
|
hash ||= window.location.hash;
|
||||||
if (!hash)
|
if (!hash)
|
||||||
return undefined;
|
return undefined;
|
||||||
// hashes consist of the file id, a dash and then the permalink anchor name
|
// hashes consist of the file id, a dash and then the permalink anchor name
|
||||||
|
|
Loading…
Reference in a new issue