|
@@ -5,7 +5,10 @@ function hideBanners() { |
|
|
|
|
|
|
|
|
/* Hide all elements with position:fixed */ |
|
|
/* Hide all elements with position:fixed */ |
|
|
const fixedElements = Array.from(document.querySelectorAll('*')) |
|
|
const fixedElements = Array.from(document.querySelectorAll('*')) |
|
|
.filter(el => getComputedStyle(el).position === 'fixed') |
|
|
|
|
|
|
|
|
.filter(el => ( |
|
|
|
|
|
getComputedStyle(el).position === 'fixed' |
|
|
|
|
|
&& el.style.opacity !== '0' // ignore if we already hid this one |
|
|
|
|
|
)) |
|
|
|
|
|
|
|
|
fixedElements.forEach(el => { |
|
|
fixedElements.forEach(el => { |
|
|
const originalDisplay = el.style.display |
|
|
const originalDisplay = el.style.display |
|
@@ -49,13 +52,17 @@ function hideBanners() { |
|
|
function main() { |
|
|
function main() { |
|
|
let state = 'off' |
|
|
let state = 'off' |
|
|
let revertSteps = [] |
|
|
let revertSteps = [] |
|
|
|
|
|
let lastRun |
|
|
|
|
|
|
|
|
function onScroll() { |
|
|
|
|
|
|
|
|
function onScroll(event) { |
|
|
let action |
|
|
let action |
|
|
if (window.scrollY > 20 && state === 'off') { |
|
|
|
|
|
|
|
|
if (window.scrollY > 20 && |
|
|
|
|
|
(state === 'off' || (state === 'on' && event.timeStamp - lastRun > 1000)) |
|
|
|
|
|
) { |
|
|
|
|
|
lastRun = event.timeStamp |
|
|
state = 'starting' |
|
|
state = 'starting' |
|
|
action = () => { |
|
|
action = () => { |
|
|
revertSteps = revertSteps.concat(hideBanners()) |
|
|
|
|
|
|
|
|
revertSteps = hideBanners().concat(revertSteps) |
|
|
state = 'on' |
|
|
state = 'on' |
|
|
} |
|
|
} |
|
|
} else if (window.scrollY <= 0 && state === 'on') { |
|
|
} else if (window.scrollY <= 0 && state === 'on') { |
|
|