Skip to content

Instantly share code, notes, and snippets.

@aaronfischer
Created April 19, 2014 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronfischer/11086100 to your computer and use it in GitHub Desktop.
Save aaronfischer/11086100 to your computer and use it in GitHub Desktop.
Waypoint.js Snippet
/*********************************************************
/
/ Waypoints
/
*********************************************************/
$(function () {
if($(window).width() >= 900 || $('html').hasClass("no-touch")){
var $links = $('.panel-nav li a[href="#' + this.id + '"]');
$('section.panel').waypoint(function(direction) {
var $links = $('.panel-nav li a[href="#' + this.id + '"]');
$links.toggleClass('active', direction === 'down');
$(this).toggleClass('active');
}, { offset: '+150' })
.waypoint(function(direction) {
var $links = $('.panel-nav li a[href="#' + this.id + '"]');
$links.toggleClass('active', direction === 'up');
$(this).toggleClass('active');
}, { offset: function () {
return -$(this).outerHeight() + 150; /* safe value */
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment