Created
February 27, 2015 14:42
-
-
Save cole007/20890f422bcadae12bc3 to your computer and use it in GitHub Desktop.
Opacity scroll effect
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
// http://stackoverflow.com/a/8702428 | |
var fadeStart=100, // 100px scroll or less will equiv to 1 opacity | |
fadeUntil=800, // 200px scroll or more will equiv to 0 opacity | |
fading = $('.slider-inner-container-fader'); | |
$(window).bind('scroll', function(){ | |
var offset = $(document).scrollTop(), | |
opacity=0; | |
if( offset<=fadeStart ){ | |
opacity=1; | |
} else if ( offset<=fadeUntil ){ | |
opacity=1-offset/fadeUntil; | |
} | |
fading.css('opacity',opacity); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment