title: Prevent jQuery action from happening a second time on scroll
body: <p>I have some code that detects if an element is in the viewport and then fires some code, it does this by calculating the distance from the top on scroll, the issue I'm having is it re-runs the code every time a scroll event happens and the element is above the fold, is there a way to make it so it only fires once? </p>
  
  <pre><code>$(document).ready(function(){
      $(document).scroll(function(){
      var scrollTop     = $(window).scrollTop(),
      elementOffset = $('.numbers').offset().top,
      distance      = (elementOffset - scrollTop);
  
      if(distance &lt; $(window).height()){
        $('.ones').delay(1000).hide(1000, function(){
         $(this).html('6').show(1000, function(){
           $(this).delay(15000).hide(1000, function(){
              $(this).html('5').show(1000);
            });
          }); 
        });
        }else{
          return false;
        }    
      });
  });
  </code></pre>