From 9e4da164607f07a74317d7bb4de280f265378aa4 Mon Sep 17 00:00:00 2001 From: Gerben Date: Sat, 10 Mar 2018 23:15:14 +0100 Subject: [PATCH] Remove unnecessary delay logic --- src/content_script.js | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/content_script.js b/src/content_script.js index 0c9c85b..7d89aaa 100644 --- a/src/content_script.js +++ b/src/content_script.js @@ -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 = [] } }