Created
December 6, 2014 22:42
-
-
Save zackproser/2d69dc09b5f848007c2b to your computer and use it in GitHub Desktop.
Use to Brighten Target Image as User Scrolls Down Target Content
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
$(document).ready(function(){ | |
var content = $('#index-content-well'); | |
var image = $('#lead-image'); | |
content.on('scroll', function(){ | |
var total_height = content.get(0).scrollHeight - content.height(); | |
var position = Math.abs(Math.round((content.scrollTop() / total_height) * 100) - 100); | |
var value = 'grayscale(' + position +'%)'; | |
image.css('-webkit-filter', value); | |
image.css('-moz-filter', value); | |
image.css('filter', value); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment