Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created July 3, 2014 20:16
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 jaredatch/daaf2071b7e1c5e1dffb to your computer and use it in GitHub Desktop.
Save jaredatch/daaf2071b7e1c5e1dffb to your computer and use it in GitHub Desktop.
jQuery floating header on scroll
jQuery(document).ready(function($){
var showed = false;
function floating_header() {
if ( $(window).width() > 700 ) {
window_scroll = $(this).scrollTop();
if ( window_scroll > 220 ) {
if ( showed == false ) {
$('#floating-header').slideDown('fast');
//alert('show');
}
showed = true;
} else {
if ( showed == true) {
$('#floating-header').slideUp('fast');
//alert('hide');
}
showed = false;
}
}
}
$(window).scroll(floating_header);
floating_header();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment