|
|
@@ -49,27 +49,14 @@ function hideBanners() { |
|
|
|
|
|
|
|
|
|
|
|
function main() { |
|
|
|
let state = 'off' |
|
|
|
let revertSteps = [] |
|
|
|
|
|
|
|
function onScroll(event) { |
|
|
|
let action |
|
|
|
if (window.scrollY > 20 && (state === 'off' || state === 'on')) { |
|
|
|
state = 'starting' |
|
|
|
action = () => { |
|
|
|
revertSteps = hideBanners().concat(revertSteps) |
|
|
|
state = 'on' |
|
|
|
} |
|
|
|
} else if (window.scrollY <= 0 && state === 'on') { |
|
|
|
state = 'stopping' |
|
|
|
action = () => { |
|
|
|
revertSteps.forEach(step => step()) |
|
|
|
revertSteps = [] |
|
|
|
state = 'off' |
|
|
|
} |
|
|
|
} |
|
|
|
if (action) { |
|
|
|
window.requestAnimationFrame(action) |
|
|
|
if (window.scrollY > 20) { |
|
|
|
revertSteps = hideBanners().concat(revertSteps) |
|
|
|
} else if (window.scrollY <= 0) { |
|
|
|
revertSteps.forEach(step => step()) |
|
|
|
revertSteps = [] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|