title: $(window).scroll being executed inside if-statement even when it doesn't meet the conditions
body: <p>I'm using a <a href="https://github.com/louisremi/jquery-smartresize" rel="nofollow">debounce script</a> as part of a conditional that will add some css to a side menu when a user scrolls a page beyond a certain amount of pixels and then hide the menu when they are a set amount of pixels from the bottom. The script works as intended for screen widths 992px and above (as per conditional <code>if (debounce_bodyWidth &gt;= 992)</code>) but it is still executing for dimensions below this. </p>
  
  <p>Is there something about <code>$(window).scroll</code> that means it is executed irrespective of conditionals?</p>
  
  <pre><code>(function ($) {
      contactDebounce = function () {
          var debounce_bodyWidth = $(window).width();
          if (debounce_bodyWidth &gt;= 992) {
              $(window).scroll(function () {
                  var distanceFromBottom = $(document).height() - $(this).scrollTop();
  
                  if (distanceFromBottom &lt;= 1200) {
                      $('.sticky-element').addClass('hide');
                  } else if ($(this).scrollTop() &gt;= 150) {
                      $('.sticky-element').removeClass('hide');
                      $('.sticky-element').css({
                          'position': 'fixed',
                          'top': '15px'
                      });
                  } else if ($(this).scrollTop() &lt; 150) {
                      $('.sticky-element').css({
                          'position': 'relative',
                          'top': '0'
                      });
                  }
              });
          }
      }
      contactDebounce();
      $(window).on("debouncedresize", contactDebounce);
  })(jQuery);
  </code></pre>