Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jhines2k7/0e8f58e3c6389404c392 to your computer and use it in GitHub Desktop.
Save jhines2k7/0e8f58e3c6389404c392 to your computer and use it in GitHub Desktop.
Sticky tail headers with different heights using the Sticky shortcut class
var tailHeaders = $('.tail-header');
for(var i = 0; i < tailHeaders.length; i++) {
new Waypoint.Sticky({
element: tailHeaders[i],
context: $('#container'),
handler: function(direction) {
var prevTailHeader = this.waypoint.previous() ? this.waypoint.previous().adapter.$element : null;
var nextTailHeader = this.waypoint.next() ? this.waypoint.next().adapter.$element : null;
if(direction === 'down' && prevTailHeader){
if(nextTailHeader.outerHeight() < prevTailHeader.outerHeight()) {
prevTailHeader.hide();
}
}
if(direction === 'up' && prevTailHeader){
if(nextTailHeader.outerHeight() < prevTailHeader.outerHeight()) {
prevTailHeader.show();
}
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment