force scroll to the blog once it's loaded
All checks were successful
Web/pipeline/head This commit looks good

This commit is contained in:
Ell 2020-12-16 23:54:06 +01:00
parent 9ddbf3be57
commit 484025fe0a
5 changed files with 16 additions and 11 deletions

View file

@ -13,6 +13,7 @@
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="../scripts/util.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics --> <!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-150032076-2"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-150032076-2"></script>
@ -41,7 +42,6 @@
<div id="content"> <div id="content">
<div id="entries"> <div id="entries">
<!-- Cookie notification --> <!-- Cookie notification -->
<script src="../scripts/cookies.js"></script>
<script src="../scripts/cookieinfo.js"></script> <script src="../scripts/cookieinfo.js"></script>
</div> </div>
<script src="index.js"></script> <script src="index.js"></script>

View file

@ -53,15 +53,7 @@ function populateManual(lang) {
sidebar.append(`<a href="https://git.ellpeck.de/Ellpeck/Web">&copy; Ellpeck</a>`); sidebar.append(`<a href="https://git.ellpeck.de/Ellpeck/Web">&copy; Ellpeck</a>`);
sidebar.append("<hr>"); sidebar.append("<hr>");
// Move to anchor now that it's loaded forceToAnchor();
if (window.location.hash.startsWith("#")) {
var anchor = $(window.location.hash);
if (anchor.length) {
$('html, body').animate({
scrollTop: anchor.offset().top
}, 0);
}
}
} }
function replaceFormatting(text) { function replaceFormatting(text) {

View file

@ -28,7 +28,7 @@
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/prettify.js"></script> <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/prettify.js"></script>
<script src="scripts/cookies.js"></script> <script src="scripts/util.js"></script>
<script src="scripts/main.js"></script> <script src="scripts/main.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics --> <!-- Global site tag (gtag.js) - Google Analytics -->

View file

@ -28,5 +28,6 @@ $.ajax({
list.append(p); list.append(p);
} }
} }
forceToAnchor();
} }
}); });

View file

@ -11,4 +11,16 @@ function setCookie(key, value, days) {
var date = new Date(); var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
document.cookie = key + "=" + value + "; expires=" + date.toUTCString(); document.cookie = key + "=" + value + "; expires=" + date.toUTCString();
}
function forceToAnchor() {
// this is probably a terrible hack
if (window.location.hash.startsWith("#")) {
var anchor = $(window.location.hash);
if (anchor.length) {
$('html, body').animate({
scrollTop: anchor.offset().top
}, 0);
}
}
} }