Fixed page hash handling
This commit is contained in:
parent
aa45f6c2eb
commit
e2bed255f1
23
js/main.js
23
js/main.js
@ -70,16 +70,29 @@ function setPage(path){
|
||||
const len = $("#article-container > article").length;
|
||||
let cnt = 0;
|
||||
$("#article-container > article").each((i, elmt) => {
|
||||
$(elmt).html(marked($(elmt).html(), markedOpt, (err, res) => {
|
||||
|
||||
marked($(elmt).html(), markedOpt, (err, res) => {
|
||||
$(elmt).html(res);
|
||||
|
||||
cnt++;
|
||||
if(cnt === len){
|
||||
if(path == "/skills"){
|
||||
// wow such ugly hack... any it works (and when it fails only the graph title disappear, so no big deal)
|
||||
setTimeout(skillsPageSetup, 500);
|
||||
skillsPageSetup();
|
||||
}
|
||||
setTimeout(() => {
|
||||
if(window.location.hash != ""){
|
||||
target = $(window.location.hash);
|
||||
if(target.length > 0){
|
||||
target = target[0];
|
||||
$('html,body').animate({
|
||||
scrollTop: (target.offsetTop)
|
||||
}, 400);
|
||||
}
|
||||
return res;
|
||||
}));
|
||||
|
||||
}
|
||||
}, 500);// I'm lazy to search a way to wait for the view engine to be updated, 500ms should be fine
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
.fail((err) => {
|
||||
|
Loading…
Reference in New Issue
Block a user