Skip to content

Instantly share code, notes, and snippets.

@zackproser
Created December 6, 2014 22:42
Show Gist options
  • Save zackproser/2d69dc09b5f848007c2b to your computer and use it in GitHub Desktop.
Save zackproser/2d69dc09b5f848007c2b to your computer and use it in GitHub Desktop.
Use to Brighten Target Image as User Scrolls Down Target Content
$(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