Last active
April 22, 2019 06:17
-
-
Save imjn/1e9e5c5307bfc4d354d9499290348f2b to your computer and use it in GitHub Desktop.
Fade in with scroll
This file contains hidden or 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 scroll_fadein(){ | |
jQuery('.fadein').each(function(){ | |
var elemPos = jQuery(this).offset().top; | |
var scroll = jQuery(window).scrollTop(); | |
var windowHeight = jQuery(window).height(); | |
if (scroll > elemPos - windowHeight + 60){ | |
jQuery(this).addClass('scrollin'); | |
} | |
}); | |
} | |
// CSS | |
.fadein { | |
opacity : 0.0; | |
transform : translate(0, 30px); | |
transition : all 500ms; | |
} | |
.fadein.scrollin { | |
opacity : 1; | |
transform : translate(0, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment