diff options
author | Minteck <contact@minteck.org> | 2022-05-13 20:21:48 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-05-13 20:21:48 +0200 |
commit | fdb02383dda84f49471d341821fc3e2607754b85 (patch) | |
tree | 58ba8016128f3a0fe66b22793919c4ffc63b1b8c /public/assets/scroll.js | |
parent | fb8bc8472b1f14faf2c9dc2f2d4c0bcbf8983b38 (diff) | |
download | vaportrail-fdb02383dda84f49471d341821fc3e2607754b85.tar.gz vaportrail-fdb02383dda84f49471d341821fc3e2607754b85.tar.bz2 vaportrail-fdb02383dda84f49471d341821fc3e2607754b85.zip |
Testing Testing 1, 2, 3
Diffstat (limited to 'public/assets/scroll.js')
-rw-r--r-- | public/assets/scroll.js | 53 |
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"); + } + } +} + |