Browse Source

force scroll to the blog once it's loaded

commissions
Ellpeck 1 month ago
parent
commit
484025fe0a
5 changed files with 16 additions and 11 deletions
  1. +1
    -1
      actaddmanual/index.html
  2. +1
    -9
      actaddmanual/index.js
  3. +1
    -1
      index.html
  4. +1
    -0
      scripts/blog.js
  5. +12
    -0
      scripts/util.js

+ 1
- 1
actaddmanual/index.html View File

@ -13,6 +13,7 @@
<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://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 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-150032076-2"></script>
@ -41,7 +42,6 @@
<div id="content">
<div id="entries">
<!-- Cookie notification -->
<script src="../scripts/cookies.js"></script>
<script src="../scripts/cookieinfo.js"></script>
</div>
<script src="index.js"></script>


+ 1
- 9
actaddmanual/index.js View File

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


+ 1
- 1
index.html View File

@ -28,7 +28,7 @@
<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="scripts/cookies.js"></script>
<script src="scripts/util.js"></script>
<script src="scripts/main.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->


+ 1
- 0
scripts/blog.js View File

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

scripts/cookies.js → scripts/util.js View File

@ -11,4 +11,16 @@ function setCookie(key, value, days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
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);
}
}
}

Loading…
Cancel
Save