Skip to content

Instantly share code, notes, and snippets.

@jholl
Created January 24, 2014 16:18
Show Gist options
  • Save jholl/8600569 to your computer and use it in GitHub Desktop.
Save jholl/8600569 to your computer and use it in GitHub Desktop.
$(document).on('scroll',function(){
var winTop = $(window).scrollTop();
var $object = $('.some-div');
$object.each(function(){
var objTopTrigger = this.offsetTop;
var objTopTriggerAdj = 400;
if (objTopTrigger + objTopTriggerAdj < winTop){
$(this).addClass('some-class');
}
if (objTopTrigger + objTopTriggerAdj > winTop){
$(this).removeClass('some-class');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment