Edited Scrollbar (WIP)

The Scrollbar anti lag initiative
This commit is contained in:
Kraken
2021-04-08 15:21:49 +02:00
parent 983cc1890c
commit 0318ffbd7a
3 changed files with 37 additions and 1 deletions
+10
View File
@@ -0,0 +1,10 @@
document.addEventListener("DOMContentLoaded", function() {
//The first argument are the elements to which the plugin shall be initialized
//The second argument has to be at least a empty object or a object with your desired options
OverlayScrollbars(document.querySelectorAll('body'), { });
});
$(function() {
//The passed argument has to be at least a empty object or a object with your desired options
$('body').overlayScrollbars({ });
});
+21
View File
@@ -0,0 +1,21 @@
/* When the user scrolls down, hide the navbar. When the user scrolls up, show the navbar */
$(document).ready(function() {
var instance = $('body').overlayScrollbars();
var prevScrollpos = instance.scroll().position.y;
console.log(prevScrollpos);
window.onscroll = function() {
var currentScrollPos = instance.scroll().position.y;
console.log(currentScrollPos);
if (prevScrollpos > currentScrollPos) {
$("#header").css({"top" : "0"});
} else {
$("#header").css({"top" : "-50px"});
}
prevScrollpos = currentScrollPos;
}
});