title: section snap to window (firefox issue)
body: <p>I have written a simple custom section snapping script, works great in chrome and safari, but after nothing happens in firefox...</p>
  
  <p>What it is does:</p>
  
  <p>When scrolling stops it checks the direction and location of each secrion... if the top of a section is within a certain range either go to the top of the page or bottom. (scroll directions is also checked). Also, it accounts for the height of a fixed header. Like I said works in Chrome and Safari. Any ideas what's wrong?</p>
  
  <pre><code>$( document ).ready(function() {
      var animating = false;
      var mainHeader = $('#main-header');
  
      var items = $("section");
      var lastOffset = 0;
      var scrollDir = 'none';
  
  
      $(window).scroll(function() {
          var windowHeight = $(this).height();
          var currOffset = $(this).scrollTop();
          var headerHeight = mainHeader.outerHeight();
  
          if (currOffset &gt; lastOffset) {
              scrollDir = 'down';
          } else {
              scrollDir = 'up';
          }
          lastOffset = currOffset;
  
  
  
          clearTimeout($.data(this, 'scrollTimer'));
          if (!animating) {
              $.data(this, 'scrollTimer', setTimeout(function() {
                  items.each(function(key, value) {
                          var currentItem = $(value);
                          var sectionOffset = currentItem.offset().top;
                          var sectionDist = sectionOffset - currOffset;
                      if ( scrollDir === 'up' &amp;&amp; sectionDist &gt; windowHeight*0.15 &amp;&amp; sectionDist &lt; windowHeight ) {
                          animating = true;
                          $('body').animate( { scrollTop: sectionOffset-windowHeight + 'px' }, 250);
                          setTimeout(function() { animating = false; }, 300);
                          return false;
                      }
                      else if ( scrollDir === 'down' &amp;&amp; sectionDist &lt; windowHeight*0.85 &amp;&amp; sectionDist &gt; 0 ) {
                          animating = true;
                          $('body').animate( { scrollTop: sectionOffset-headerHeight + 'px' }, 250);
                          setTimeout(function() { animating = false; }, 300);
                          return false;
                      }
                });
              }, 200));
          }
      });
  });
  </code></pre>