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-")) {
|
if (window.location.hash.startsWith("#blog-")) {
|
||||||
var anchor = $(window.location.hash);
|
var anchor = $(window.location.hash);
|
||||||
if (anchor.length) {
|
if (anchor.length) {
|
||||||
openBlogPost(window.location.hash.substring(6));
|
openBlogPost(window.location.hash.substring(6), function () {
|
||||||
$('html, body').animate({
|
$('html, body').animate({
|
||||||
scrollTop: anchor.offset().top
|
scrollTop: anchor.offset().top
|
||||||
}, 0)
|
}, 0)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function openBlogPost(id) {
|
function openBlogPost(id, onDone) {
|
||||||
$.get("blog/" + id + ".md", function (markdown) {
|
$.get("blog/" + id + ".md", function (markdown) {
|
||||||
let html = converter.makeHtml(markdown);
|
let html = converter.makeHtml(markdown);
|
||||||
$("#blog-post-" + id).html(html);
|
$("#blog-post-" + id).html(html);
|
||||||
|
@ -61,5 +62,8 @@ function openBlogPost(id) {
|
||||||
var discuss = $("#blog-discuss-" + id);
|
var discuss = $("#blog-discuss-" + id);
|
||||||
if (discuss.length)
|
if (discuss.length)
|
||||||
discuss.html("Discuss this post");
|
discuss.html("Discuss this post");
|
||||||
|
|
||||||
|
if (onDone)
|
||||||
|
onDone();
|
||||||
});
|
});
|
||||||
}
|
}
|
Loading…
Reference in a new issue