Skip to content
Snippets Groups Projects
Commit c77ed2a0 authored by Austin Anderson's avatar Austin Anderson
Browse files

Another method of scrolling

parent b22d7436
No related branches found
No related tags found
No related merge requests found
...@@ -104,21 +104,14 @@ $(function () { ...@@ -104,21 +104,14 @@ $(function () {
// Nothing to do if no hash in the URL // Nothing to do if no hash in the URL
if (window.location.hash.length <= 1) { if (window.location.hash.length <= 1) {
// Empty! // Empty!
// If the hash matches a Category on the page, then scroll to it once the // If the hash matches a Category on the page, then scroll to it
// window gets focus (this handles e.g. if opened in the background)
} else if ($("span[id='" + unescaped + "']").length) { } else if ($("span[id='" + unescaped + "']").length) {
let scrolled = false setTimeout(function () {
console.log("ID detected") document.getElementById.scrollIntoView({
$(window).focus(function() { behavior: "smooth",
console.log("Running window focus handler") block: "start",
if (!scrolled) {
console.log("Scrolling in the window focus handler")
document.getElementById(unescaped).scrollIntoView({
behavior: 'smooth'
});
scrolled = true
}
}); });
}, 100);
// If the hash is exactly 41 chars (hash sign # plus a 40-char sha hash), // If the hash is exactly 41 chars (hash sign # plus a 40-char sha hash),
// just show that modal. // just show that modal.
} else if (window.location.hash.length == 41) { } else if (window.location.hash.length == 41) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment