Skip to content

Instantly share code, notes, and snippets.

@arvindang
Created December 22, 2014 16:32
Show Gist options
  • Save arvindang/fce936a0bff1bd29396f to your computer and use it in GitHub Desktop.
Save arvindang/fce936a0bff1bd29396f to your computer and use it in GitHub Desktop.
Sticky header using waypoint plugin
$('#opening, #film, #practical, #conference, #guide')
.waypoint(function(direction) {
// sticky header
$(this).find('> div > header').toggleClass('sticky', direction === 'down');
// nav .current
currentNav($(this).attr('id'), direction === 'down');
})
.waypoint(function(direction) {
// nav .current
currentNav($(this).attr('id'), direction === 'up');
}, {
offset: function() {
return - $(this).outerHeight();
}
})
.waypoint(function(direction) {
// sticky header
$(this).find('> div > header').toggleClass('sticky-bottom', direction === 'down');
}, {
offset: function() {
return - $(this).outerHeight() + $(this).find('> div > header').outerHeight();
}
});
$('body > header + section').waypoint(function(direction) {
$nav.toggleClass('wide', direction === 'down');
});
@arvindang
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment