CHANGE use scrolllistener only when site is 1.5 times the screen size
This commit is contained in:
parent
a25ea40300
commit
a2e23623d6
1 changed files with 10 additions and 7 deletions
|
@ -1,12 +1,15 @@
|
||||||
window.addEventListener("scroll", () => {
|
window.addEventListener("scroll", () => {
|
||||||
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
|
var height = document.documentElement.scrollHeight;
|
||||||
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
|
if ((height / window.screen.availHeight ) > 1.5) {
|
||||||
var scrolled = (winScroll / height) * 100;
|
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
|
||||||
document.getElementById('progress').style.width = scrolled + "%";
|
height = height - document.documentElement.clientHeight;
|
||||||
|
var scrolled = (winScroll / height) * 100;
|
||||||
|
document.getElementById('progress').style.width = scrolled + "%";
|
||||||
|
|
||||||
const toTop = document.getElementById('totop');
|
const toTop = document.getElementById('totop');
|
||||||
|
|
||||||
if ((window.scrollY > 0 && !toTop.classList.contains("show")) || (window.scrollY <= 0 && toTop.classList.contains("show"))) {
|
if ((window.scrollY > 0 && !toTop.classList.contains("show")) || (window.scrollY <= 0 && toTop.classList.contains("show"))) {
|
||||||
toTop.classList.toggle("show");
|
toTop.classList.toggle("show");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
Loading…
Reference in a new issue