Skip to content

Instantly share code, notes, and snippets.

@CB9TOIIIA
Created October 30, 2016 14:38
Show Gist options
  • Select an option

  • Save CB9TOIIIA/f821d2b84f4b96d8716da4a2179aecf9 to your computer and use it in GitHub Desktop.

Select an option

Save CB9TOIIIA/f821d2b84f4b96d8716da4a2179aecf9 to your computer and use it in GitHub Desktop.
affix простое меню
function MobileDetect() {
var UA = navigator.userAgent.toLowerCase();
return (/android|webos|iris|bolt|mobile|iphone|ipad|ipod|iemobile|blackberry|windows phone|opera mobi|opera mini/i.test(UA)) ? true : false;
}
jQuery(document).ready(function($) {
if (!MobileDetect()) {
var header = $("#header .main-menu");
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll > 200) {
header.addClass("affixmenu").fadeIn("slow");
}
if (scroll > 160 && scroll < 190) {
header.addClass("affixmenu").fadeOut("slow");
}
if (scroll < 160) {
header.removeClass("affixmenu").fadeIn("slow");
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment