Skip to content

Instantly share code, notes, and snippets.

@ruizfrontend
Created July 11, 2013 11:45
Show Gist options
  • Save ruizfrontend/5974750 to your computer and use it in GitHub Desktop.
Save ruizfrontend/5974750 to your computer and use it in GitHub Desktop.
waypoints samples
$('ELEMENT').waypoint( function(direction) {
if (direction == 'down') {
console.log($(this).attr('id'), 'disappears top');
} else {
console.log($(this).attr('id'), 'appears top');
}
}, { offset: function(){
return -$(this).height();
}, triggerOnce: true, continuous: true})
$('ELEMENT').waypoint( function(direction) {
if (direction == 'down') {
console.log($(this).attr('id'), 'appears bottoms');
} else {
console.log($(this).attr('id'), 'disappears bottoms');
}
}, { offset: function(){
return $.waypoints('viewportHeight');
}, continuous: true})
$('ELEMENT').waypoint( function(direction) {
if (direction == 'down') {
console.log($(this).attr('id'), 'next element appears');
} else {
console.log($(this).attr('id'), 'next element is no more');
}
}, { offset: 'bottom-in-view', continuous: true})
$('ELEMENT').waypoint( function(direction) {
if (direction == 'down') {
console.log($(this).attr('id'), 'previous element is no more');
} else {
console.log($(this).attr('id'), 'previous element appears');
}
}, { offset: function(){
return -$(this).height();
}, continuous: true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment