Created
October 30, 2016 14:38
-
-
Save CB9TOIIIA/f821d2b84f4b96d8716da4a2179aecf9 to your computer and use it in GitHub Desktop.
affix простое меню
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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