fixed a long standing bug with blog posts towards the bottom not being scrolled to properly
This commit is contained in:
parent
b689f4cb74
commit
2c22698067
1 changed files with 9 additions and 5 deletions
|
@ -44,16 +44,17 @@ $.ajax({
|
|||
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)
|
||||
openBlogPost(window.location.hash.substring(6), function () {
|
||||
$('html, body').animate({
|
||||
scrollTop: anchor.offset().top
|
||||
}, 0)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function openBlogPost(id) {
|
||||
function openBlogPost(id, onDone) {
|
||||
$.get("blog/" + id + ".md", function (markdown) {
|
||||
let html = converter.makeHtml(markdown);
|
||||
$("#blog-post-" + id).html(html);
|
||||
|
@ -61,5 +62,8 @@ function openBlogPost(id) {
|
|||
var discuss = $("#blog-discuss-" + id);
|
||||
if (discuss.length)
|
||||
discuss.html("Discuss this post");
|
||||
|
||||
if (onDone)
|
||||
onDone();
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue