fix autoscroll not working on slow connections

This commit is contained in:
Ellpeck 2019-02-17 01:56:31 +01:00
parent 2e1bca75e3
commit 76be31d38e
2 changed files with 11 additions and 13 deletions

View file

@ -26,6 +26,16 @@ $.getJSON("blog/posts.json", function (json) {
}
});
}
if (window.location.hash.startsWith("#blog-")) {
var anchor = $(window.location.hash);
if (anchor.length) {
openBlogPost(window.location.hash.substring(6));
$('html, body').animate({
scrollTop: anchor.offset().top
}, 0)
}
}
});
function openBlogPost(id) {

View file

@ -13,9 +13,7 @@ $(function () {
}
}
}
let hash = window.location.hash;
openModals(hash);
openModals(window.location.hash);
$('a').on('click', function () {
openModals($(this).attr('href'));
});;
@ -35,16 +33,6 @@ $(function () {
window.location.hash = "";
location.reload();
});
if (hash.startsWith("#blog-")) {
var anchor = $(hash);
if (anchor.length) {
openBlogPost(hash.substring(6));
$('html, body').animate({
scrollTop: anchor.offset().top
}, 0)
}
}
});
function getCookie(key) {