|
@@ -49,27 +49,14 @@ function hideBanners() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function main() { |
|
|
function main() { |
|
|
let state = 'off' |
|
|
|
|
|
let revertSteps = [] |
|
|
let revertSteps = [] |
|
|
|
|
|
|
|
|
function onScroll(event) { |
|
|
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 = [] |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|