title: window.resize and window.innerwidth height issues?
body: <p>Having a bit of an issue with some Javascript/JQuery code.</p>
  
  <p>The site we use has two menus - one for desktop and one for mobile. The desktop menu goes direct to pages but the mobile version has some added functionality of a drop-down sub-menu for certain parts of the site (using an addClass method for if the sub-menu is expanded etc.)</p>
  
  <p>Ordinarily this works OK - however it seems that resizing the height of the window in Chrome can cause from time to time for the code to be ignored. However, playing around with the height again can make it work again.</p>
  
  <p>This is an issue especially when using the site on mobile devices such as Chrome on Android - as the address bar being hidden causes a height resize of the window - and the menu functionality stops working.
  However when the address bar is on screen - it works OK.</p>
  
  <p>It appears to be doing this on a random basis as I cannot find a height breakpoint for when the code is ignored.</p>
  
  <p>The below code should clarify the situation further</p>
  
  <pre><code>$(document).ready(function() {
      topnavigation(), window.innerWidth &lt; 767 &amp;&amp; ($("#services").click(function() {
          $(this).hasClass("expanded") ? $(this).removeClass("expanded") : $(this).addClass("expanded"), event.preventDefault(), $(".subnav2").toggle()
      }), $("#creative").click(function() {
          return $(this).hasClass("expanded") ? $(this).removeClass("expanded") : $(this).addClass("expanded"), $("#creativenav").toggle(), !1
      }), $("#marketing").click(function() {
          return $(this).hasClass("expanded") ? $(this).removeClass("expanded") : $(this).addClass("expanded"), $("#marketingnav").toggle(), !1
      }), $("#digital").click(function() {
          return $(this).hasClass("expanded") ? $(this).removeClass("expanded") : $(this).addClass("expanded"), $("#digitalnav").toggle(), !1
      }), $("#med-ed").click(function() {
          return $(this).hasClass("expanded") ? $(this).removeClass("expanded") : $(this).addClass("expanded"), $("#med-ednav").toggle(), !1
      })), 
  
  
      $(window).resize(function() {
          var width = jQuery(window).width();
          var height = jQuery(window).height();
  
          console.log(window.innerWidth);
          topnavigation(), window.innerWidth &lt; 767 ? ($("#services").click(function() {
              $(this).hasClass("expanded") ? $(this).removeClass("expanded") : $(this).addClass("expanded"), event.preventDefault(), $(".subnav2").toggle()
          }), 
  
          $("#creative").click(function() {
              return $(this).hasClass("expanded") ? $(this).removeClass("expanded") : $(this).addClass("expanded"), $("#creativenav").toggle(), !1
          }), 
  
          $("#marketing").click(function() {
              return $(this).hasClass("expanded") ? $(this).removeClass("expanded") : $(this).addClass("expanded"), $("#marketingnav").toggle(), !1
          }),
  
           $("#digital").click(function() {
              return $(this).hasClass("expanded") ? $(this).removeClass("expanded") : $(this).addClass("expanded"), $("#digitalnav").toggle(), !1
          }), 
  
           $("#med-ed").click(function() {
              return $(this).hasClass("expanded") ? $(this).removeClass("expanded") : $(this).addClass("expanded"), $("#med-ednav").toggle(), !1
          })) : $("#services").click(function() {
              $(".subnav2").hide(), window.location = "#"
          }), 
  
          window.innerWidth &gt;= 768 &amp;&amp; ($(".nav-collapse").removeClass("opened"), $(".nav-collapse").addClass("closed"), $(".nav-collapse").css("position", "absolute"), $(".nav-collapse").removeClass("expanded"), $(".nav-toggle").removeClass("active"), $(".subnav2").hide())
      })
  
  
  })
  </code></pre>
  
  <p>I will point out that topnavigation() is not a factor in this issue - as this is for a sticky nav and removing the sticky nav functionality still caused this height-based issue.</p>
  
  <p>Is there any further reason why this may be happening?</p>