mirror of
https://github.com/Ellpeck/ObsidianJustSharePlease.git
synced 2024-11-26 12:18:35 +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");
|
||||
$(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();
|
||||
|
||||
function display() {
|
||||
|
@ -92,8 +97,8 @@
|
|||
});
|
||||
}
|
||||
|
||||
function getId() {
|
||||
let hash = window.location.hash;
|
||||
function getId(hash) {
|
||||
hash ||= window.location.hash;
|
||||
if (!hash)
|
||||
return undefined;
|
||||
// hashes consist of the file id, a dash and then the permalink anchor name
|
||||
|
|
Loading…
Reference in a new issue