Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active December 7, 2018 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplit/3a0aef69730d02c7108f817dd8dc6b13 to your computer and use it in GitHub Desktop.
Save wplit/3a0aef69730d02c7108f817dd8dc6b13 to your computer and use it in GitHub Desktop.
add fade out effect to element on scroll
jQuery(function( $ ){
var element = $( ".element-class" );
function fade_element() {
window_scroll = $(this).scrollTop();
element.css({
'opacity' : 1-(window_scroll/300),
'transform' : "translate(0,"+ +(window_scroll/2) + "px)" });
});
}
$(window).scroll(function() {
fade_element();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment