Last active
August 29, 2015 14:25
-
-
Save jhines2k7/0e8f58e3c6389404c392 to your computer and use it in GitHub Desktop.
Sticky tail headers with different heights using the Sticky shortcut class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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