Skip to content

Instantly share code, notes, and snippets.

@jholl
Created January 24, 2014 16:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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