Skip to content

Instantly share code, notes, and snippets.

@e1en0r
Created March 22, 2011 20:49
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 e1en0r/882016 to your computer and use it in GitHub Desktop.
Save e1en0r/882016 to your computer and use it in GitHub Desktop.
An alternative to Phork/it's current demo.js nav positioning method. This will slide the nav on scroll rather than fix its position.
var $nav = $('div.columns .column.right').each(function() {
var $this = $(this)
$window = $(window),
$document = $(document)
;
if ($this.height() + $this.offset().top < $window.height() - $('#footer-shift').height()) {
$this
.data('top', $this.position().top)
.css('position', 'absolute')
;
$document.bind('scroll', function(immediate) {
clearTimeout(timeout);
var timeout = setTimeout(function() {
$this.stop().animate({
top: Math.max($document.scrollTop(), $this.data('top'))
}, 1000);
}, immediate ? 0 : 500);
}).trigger('scroll');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment