Skip to content

Instantly share code, notes, and snippets.

@itamar
Created June 2, 2013 18:28
Show Gist options
  • Select an option

  • Save itamar/5694401 to your computer and use it in GitHub Desktop.

Select an option

Save itamar/5694401 to your computer and use it in GitHub Desktop.
Sticky sidebar
# Sticky Sidebar
$(document).ready () ->
if (!!$('.sticky').offset())
stickyTop = $('.sticky').offset().top
$(window).scroll () ->
windowTop = $(window).scrollTop()
if (stickyTop < windowTop)
$('.sticky').css({ position: 'fixed', top: 0 });
else
$('.sticky').css('position','static');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment