make sure anchors are actually scrolled to once they are loaded

This commit is contained in:
Ell 2023-08-17 13:51:31 +02:00
parent 1d83851102
commit 44c706f4a4

View file

@ -63,9 +63,12 @@
main.html(DOMPurify.sanitize(md.render(t))); main.html(DOMPurify.sanitize(md.render(t)));
// scroll to anchor // scroll to anchor
$(() => {
console.log("Loaded!");
let element = $(window.location.hash); let element = $(window.location.hash);
if (element.length) if (element.length)
$(window).scrollTop(element.offset().top); $(window).scrollTop(element.offset().top);
});
}, },
error: (r, s, e) => main.html(`<div class="error"><p>Error loading shared note with id <code>${id}</code>: ${e}</p><p><a href="#">Home</a></p></div>`) error: (r, s, e) => main.html(`<div class="error"><p>Error loading shared note with id <code>${id}</code>: ${e}</p><p><a href="#">Home</a></p></div>`)
}); });