Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hide / show element depending on scroll position
(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'))
@Lewiscowles1986

This comment has been minimized.

Copy link
Owner Author

commented Oct 23, 2018

for facebook (where I tested this) the below CSS should be injected (inspect element put inside a <style></style> tag

#rightCol {
    transition: opacity 1s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.