|
@@ -47,20 +47,28 @@ function hideBanners() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function startCheckingLoop() { |
|
|
|
|
|
|
|
|
function main() { |
|
|
|
|
|
let active = false |
|
|
let revert |
|
|
let revert |
|
|
|
|
|
|
|
|
function checkScroll() { |
|
|
|
|
|
if (window.scrollY > 20 && !revert) { |
|
|
|
|
|
revert = hideBanners() |
|
|
|
|
|
} else if (window.scrollY <= 0 && revert) { |
|
|
|
|
|
revert() |
|
|
|
|
|
revert = undefined |
|
|
|
|
|
|
|
|
function onScroll() { |
|
|
|
|
|
let action |
|
|
|
|
|
if (window.scrollY > 20 && !active) { |
|
|
|
|
|
active = true |
|
|
|
|
|
action = () => { revert = hideBanners() } |
|
|
|
|
|
} else if (window.scrollY <= 0 && active) { |
|
|
|
|
|
active = false |
|
|
|
|
|
action = () => { |
|
|
|
|
|
revert && revert() |
|
|
|
|
|
revert = undefined |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (action) { |
|
|
|
|
|
window.requestAnimationFrame(action) |
|
|
} |
|
|
} |
|
|
window.requestAnimationFrame(checkScroll); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
window.requestAnimationFrame(checkScroll); |
|
|
|
|
|
|
|
|
window.addEventListener('scroll', onScroll) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
startCheckingLoop(); |
|
|
|
|
|
|
|
|
main() |