title: onscroll event executes only once
body: <p>I'm using this code to get offset of an element in the page while scrolling but the scroll function is executed only once and alerts the viewportWidth then it stops at the 'off' variable</p>
  
  <p>This is a simple example from the original script it's not just about setting the #menuIcon as fixed all the time</p>
  
  <pre><code>$(document).ready(function(){
  document.body.style.overflow = "hidden";
  var viewportWidth = $(window).innerWidth();
  document.body.style.overflow = "";
  window.onscroll = scrolls(viewportWidth);
  });
  
  function scrolls(viewportWidth){
  alert(viewportWidth);
  if(viewportWidth&gt;100 &amp;&amp; viewportWidth&lt;=820){
      alert('test');
      var w = $(window);
      var offset = $("#menuIcon").offset();
      var off = offset.top-w.scrollTop();
      if(off&lt;='10'){
          $("#menuIcon").css({"position":"fixed","top":"20px"});
      }
  }
  }
  </code></pre>
  
  <p><a href="https://jsfiddle.net/n8vms2js/2/" rel="nofollow">jsfiddle</a></p>