Created
October 23, 2018 18:57
-
-
Save Lewiscowles1986/90833511b8d3db6c81be7eb503bab787 to your computer and use it in GitHub Desktop.
Hide / show element depending on scroll position
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(target, threshold, elem) { | |
listener = () => { | |
if (target.scrollY > threshold) { | |
elem.style.opacity = 1; | |
} else { | |
elem.style.opacity = 0; | |
} | |
}; | |
target.addEventListener( | |
'scroll', | |
listener, | |
false | |
); | |
})(window, 300, document.querySelector('#rightCol')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for facebook (where I tested this) the below CSS should be injected (inspect element put inside a
<style></style>
tag