title: Unlimited loop with jquery and $(window).resize function
body: <p>I'd like to make a auto scroll to focus function for mobile users, so they won't have trouble with the keyboard anymore wich is sometimes overlapping the inputs.<br/>
  ->If someone clicks on a input the page scrolls down to this, -64px because of fixed navigation.<br/> <br/>
  My problem is if for example a tablet user change view from landscape to portrait the function could not work because i set up:</p>
  
  <pre><code>if ($( window ).width() &lt;= 1250) {});
  </code></pre>
  
  <p>So i made a call function like that:</p>
  
  <pre><code>$(window).resize(function() {
      resizeFix();
  });
  </code></pre>
  
  <p>But the problem is it loops infinite times after changed window width.<br/><br/><br/>
  The whole code:</p>
  
  <pre><code>$(document).ready(function(){ 
      resizeFix = function() {
              if ($( window ).width() &lt;= 1250) {
              $('input[type=text], input[type=checkbox], input[type=password], textarea').focus(function() {
                      $('html, body').animate({
                          scrollTop: $('input:focus, textarea:focus').offset().top - 64
                      }, 500);
                  });
              };
  
      };
  
    resizeFix();
  
      $(window).resize(function() {
          resizeFix();
      });
  });
  </code></pre>
  
  <p>EDIT: I already tried:<br/></p>
  
  <pre><code>$(window).resize(function() {
    if ($( window ).width() &lt;= 1250) {
      resizeFix();
   });
  });
  </code></pre>