aboutsummaryrefslogtreecommitdiff
path: root/public/assets/scroll.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/scroll.js')
-rw-r--r--public/assets/scroll.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/public/assets/scroll.js b/public/assets/scroll.js
new file mode 100644
index 0000000..a0c6b78
--- /dev/null
+++ b/public/assets/scroll.js
@@ -0,0 +1,53 @@
+function posY(elm) {
+ var test = elm, top = 0;
+
+ while(!!test && test.tagName.toLowerCase() !== "body") {
+ top += test.offsetTop;
+ test = test.offsetParent;
+ }
+
+ return top;
+}
+
+function viewPortHeight() {
+ var de = document.documentElement;
+
+ if(!!window.innerWidth)
+ { return window.innerHeight; }
+ else if( de && !isNaN(de.clientHeight) )
+ { return de.clientHeight; }
+
+ return 0;
+}
+
+function scrollY() {
+ if( window.pageYOffset ) { return window.pageYOffset; }
+ return Math.max(document.documentElement.scrollTop, document.body.scrollTop);
+}
+
+function checkvisible( elm ) {
+ var vpH = viewPortHeight(), // Viewport Height
+ st = scrollY(), // Scroll Top
+ y = posY(elm);
+
+ return (y > (vpH + st));
+}
+
+document.body.innerHTML = document.body.innerHTML.replaceAll("\n", "").replace(/> *</gm, "><").trim();
+
+window.onscroll = () => {
+ if (window.innerWidth > 700) {
+ if (window.scrollY() > (window.innerHeight - 52)) {
+ document.getElementsByClassName("navbar")[0].classList.add("scrolled");
+ } else {
+ document.getElementsByClassName("navbar")[0].classList.remove("scrolled");
+ }
+ } else {
+ if (window.scrollY() > (window.innerHeight - 120)) {
+ document.getElementsByClassName("navbar")[0].classList.add("scrolled");
+ } else {
+ document.getElementsByClassName("navbar")[0].classList.remove("scrolled");
+ }
+ }
+}
+