|
|
@@ -42,25 +42,28 @@ function hideBanners() { |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
const revert = () => revertSteps.forEach(step => step()) |
|
|
|
return revert |
|
|
|
return revertSteps |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function main() { |
|
|
|
let active = false |
|
|
|
let revert |
|
|
|
let state = 'off' |
|
|
|
let revertSteps = [] |
|
|
|
|
|
|
|
function onScroll() { |
|
|
|
let action |
|
|
|
if (window.scrollY > 20 && !active) { |
|
|
|
active = true |
|
|
|
action = () => { revert = hideBanners() } |
|
|
|
} else if (window.scrollY <= 0 && active) { |
|
|
|
active = false |
|
|
|
if (window.scrollY > 20 && state === 'off') { |
|
|
|
state = 'starting' |
|
|
|
action = () => { |
|
|
|
revert && revert() |
|
|
|
revert = undefined |
|
|
|
revertSteps = revertSteps.concat(hideBanners()) |
|
|
|
state = 'on' |
|
|
|
} |
|
|
|
} else if (window.scrollY <= 0 && state === 'on') { |
|
|
|
state = 'stopping' |
|
|
|
action = () => { |
|
|
|
revertSteps.forEach(step => step()) |
|
|
|
revertSteps = [] |
|
|
|
state = 'off' |
|
|
|
} |
|
|
|
} |
|
|
|
if (action) { |
|
|
|