Advertisement
deliciousthemes

Responsive Navigation

Dec 6th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.50 KB | None | 0 0
  1. jQuery(document).ready(function() {
  2.     // Responsive Navigation
  3.  
  4.     var nava = jQuery(".nav-btn"),
  5.         navb = jQuery("#navigation"),
  6.         wind = jQuery(window).width(), 
  7.         winh;
  8.        
  9.         if(wind < 1007) {
  10.              winh = jQuery(window).outerHeight()
  11.         }
  12.         else {
  13.             winh = jQuery(window).outerHeight() -jQuery('#header').outerHeight()
  14.         }
  15.  
  16.     // Add classes     
  17.     jQuery(window).resize(function () {
  18.         var nava = jQuery(".nav-btn"),
  19.             navb = jQuery("#navigation"),
  20.             wind = jQuery(window).width(),
  21.             winh;
  22.  
  23.         if(wind < 1007) {
  24.              winh = jQuery(window).outerHeight()
  25.         }
  26.         else {
  27.             winh = jQuery(window).outerHeight() -jQuery('#header').outerHeight()
  28.         }
  29.        
  30.         if (wind > 1006) {
  31.             navb.addClass("desktop");
  32.             navb.removeClass("mobile")
  33.         }
  34.         if (wind < 1007) {
  35.             navb.addClass("mobile");
  36.             navb.removeClass("desktop")
  37.         }
  38.  
  39.         // Nav CSS adjustment for mobile
  40.         if (wind < 1007) {
  41.         jQuery('#navigation.mobile').css({'max-height': winh-150, 'overflow-y': 'scroll'});
  42.         }
  43.         if (wind > 1006) {
  44.             jQuery('#navigation.desktop').css({'overflow': 'visible'});
  45.         }      
  46.  
  47.     });
  48.            
  49.         if (wind > 1006) {
  50.             navb.addClass("desktop");
  51.             navb.removeClass("mobile")
  52.         }
  53.         if (wind < 1007) {
  54.             navb.addClass("mobile");
  55.             navb.removeClass("desktop")
  56.         }  
  57.         // Nav CSS adjustment for mobile
  58.         if (wind < 1007) {
  59.         jQuery('#navigation.mobile').css({'max-height': winh-150, 'overflow-y': 'scroll'});
  60.         }
  61.         if (wind > 1006) {
  62.             jQuery('#navigation.desktop').css({'overflow': 'visible'});
  63.         }              
  64.  
  65. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement