Last active
December 7, 2018 00:14
-
-
Save wplit/3a0aef69730d02c7108f817dd8dc6b13 to your computer and use it in GitHub Desktop.
add fade out effect to element on scroll
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
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