Skip to content

Instantly share code, notes, and snippets.

@ourmaninamsterdam
Created July 25, 2013 12:01
Show Gist options
  • Save ourmaninamsterdam/6079009 to your computer and use it in GitHub Desktop.
Save ourmaninamsterdam/6079009 to your computer and use it in GitHub Desktop.
jQuery waypoints
Setup waypoints for each block
$('.js-block').each(function(){
addWaypoint( $(this), 'down' );
addWaypoint( $(this), 'up' );
});
function addWaypoint( $elem, direction ){
var thisID = that.formatID( $elem.attr('id') ),
nextID = $elem.next('.js-block').attr('id') || null;
$elem.waypoint( function( ){
waypointHandler( $elem );
},{
offset : function(){
if( direction === 'up' ){
return getOffset( thisID, nextID, 'up' );
}
return -CONFIG.pageWaypoints[ thisID ];
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment