-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
21 lines (18 loc) · 898 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
document.addEventListener("DOMContentLoaded", function() {
var footer = document.querySelector("footer");
var isFooterVisible = false;
window.addEventListener("scroll", function() {
var scrollHeight = document.documentElement.scrollHeight;
var clientHeight = document.documentElement.clientHeight;
var scrollTop = window.scrollY || window.pageYOffset || document.body.scrollTop + (document.documentElement && document.documentElement.scrollTop || 0);
var scrollPosition = scrollHeight - clientHeight - scrollTop;
var threshold = 100;
if (scrollPosition < threshold && !isFooterVisible) {
footer.style.bottom = "0";
isFooterVisible = true;
} else if (scrollPosition >= threshold && isFooterVisible) {
footer.style.bottom = "-50px";
isFooterVisible = false;
}
});
});