Skip to content

Instantly share code, notes, and snippets.

@cesarkohl
Created October 4, 2015 01:38
Show Gist options
  • Select an option

  • Save cesarkohl/115e94ce4b8103640f05 to your computer and use it in GitHub Desktop.

Select an option

Save cesarkohl/115e94ce4b8103640f05 to your computer and use it in GitHub Desktop.
jQuery fixed menu
// Fixed Menu
slider($(window).height());
$(window).scroll(function () {
slider($(window).height());
});
function slider(vh_height) {
console.log('scrollTop: '+ document.body.scrollTop +' | vh_height: '+vh_height);
if (document.body.scrollTop > vh_height)
$('nav.navbar').stop().animate({ top: 0 }, 200);
else
$('nav.navbar').stop().animate({ top: '-100px' }, 200);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment