title: jQuery scrollTop a little jumpy
body: <p>I am building a site with vertical scroll.</p>
  
  <p>I have implemented the jquery below:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $("document").ready(function() {            
  
              $('.homebutton').click(function(){
  
                  $('html, body').animate({
                      scrollTop: $("#home").offset().top
                  }, 1500);                  
  
  
               });
  
  
  
              $('.aboutbutton').click(function(){
  
                  $('html, body').animate({
                      scrollTop: $("#about").offset().top
                  }, 1500);                  
  
  
               });
  
  
              $('.portfoliobutton').click(function(){
  
                  $('html, body').animate({
                      scrollTop: $("#portfolio").offset().top
                  }, 1500);                  
  
  
               });
  
  
  
              $('.contactbutton').click(function(){
  
                  $('html, body').animate({
                      scrollTop: $("#contact").offset().top
                  }, 1500);                  
  
  
               });
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>With the following HTML :</p>
  
  <pre><code>&lt;div id="wrapper"&gt;
  
  &lt;div id="home" class="tab home"&gt;
  
      &lt;div class="header"&gt;
  
          &lt;div class="logo"&gt;
  
              &lt;img src="images/logo.jpg" /&gt;
  
          &lt;/div&gt;
  
          &lt;div class="menuholder"&gt;
  
              &lt;ul id="homemenu" class="menu"&gt;
  
                  &lt;li&gt;&lt;a class="active homebutton" href="#home"&gt;HOME&lt;br /&gt;&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a class="aboutbutton" href="#about"&gt;ABOUT&lt;br /&gt;&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a class="portfoliobutton" href="#portfolio"&gt;PORTFOLIO&lt;br /&gt;&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a class="contactbutton" href="#contact"&gt;CONTACT&lt;br /&gt;&lt;/a&gt;   &lt;/li&gt;
  
              &lt;/ul&gt;
  
          &lt;/div&gt;
  
          &lt;div class="clr"&gt;&lt;/div&gt;
  
      &lt;/div&gt;
  
      &lt;div class="content"&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;div id="about" class="tab"&gt;
  
      &lt;div class="header"&gt;
  
          &lt;div class="logo"&gt;
  
              &lt;img src="images/logo.jpg" /&gt;
  
          &lt;/div&gt;
  
          &lt;div class="menuholder"&gt;
  
              &lt;ul id="aboutmenu" class="menu"&gt;
  
                  &lt;li&gt;&lt;a href="#home" class="homebutton"&gt;HOME&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a class="active aboutbutton" href="#about"&gt;ABOUT&lt;br /&gt;&lt;span&gt;All you need to know&lt;/span&gt;&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a href="#portfolio" class="portfoliobutton"&gt;PORTFOLIO&lt;br /&gt;&lt;span&gt;See what we can do!&lt;/span&gt;&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a href="#contact" class="contactbutton"&gt;CONTACT&lt;br /&gt;&lt;span&gt;Get in touch and say HI!&lt;/span&gt;&lt;/a&gt;   &lt;/li&gt;
  
              &lt;/ul&gt;
  
          &lt;/div&gt;
  
      &lt;/div&gt;
  
      &lt;div class="content"&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;div id="portfolio" class="tab"&gt;
  
      &lt;div class="header"&gt;
  
          &lt;div class="logo"&gt;
  
              &lt;img src="images/logo.jpg" /&gt;
  
          &lt;/div&gt;
  
          &lt;div class="menuholder"&gt;
  
              &lt;ul id="portfoliomenu" class="menu"&gt;
  
                  &lt;li&gt;&lt;a href="#home" class="homebutton"&gt;HOME&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a href="#about" class="aboutbutton"&gt;ABOUT&lt;br /&gt;&lt;span&gt;All you need to know&lt;/span&gt;&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a class="active portfoliobutton" href="#portfolio"&gt;PORTFOLIO&lt;br /&gt;&lt;span&gt;See what we can do!&lt;/span&gt;&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a href="#contact" class="contactbutton"&gt;CONTACT&lt;br /&gt;&lt;span&gt;Get in touch and say HI!&lt;/span&gt;&lt;/a&gt;   &lt;/li&gt;
  
              &lt;/ul&gt;
  
          &lt;/div&gt;
  
      &lt;/div&gt;
  
      &lt;div class="content"&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;div id="contact" class="tab"&gt;
  
      &lt;div class="header"&gt;
  
          &lt;div class="logo"&gt;
  
              &lt;img src="images/logo.jpg" /&gt;
  
          &lt;/div&gt;
  
          &lt;div class="menuholder"&gt;
  
              &lt;ul id="contactmenu" class="menu"&gt;
  
                  &lt;li&gt;&lt;a href="#home" class="homebutton"&gt;HOME&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a href="#about" class="aboutbutton"&gt;ABOUT&lt;br /&gt;&lt;span&gt;All you need to know&lt;/span&gt;&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a href="#portfolio" class="portfoliobutton"&gt;PORTFOLIO&lt;br /&gt;&lt;span&gt;See what we can do!&lt;/span&gt;&lt;/a&gt;   &lt;/li&gt;
                  &lt;li&gt;&lt;a class="active contactbutton" href="#contact"&gt;CONTACT&lt;br /&gt;&lt;span&gt;Get in touch and say HI!&lt;/span&gt;&lt;/a&gt;   &lt;/li&gt;
  
              &lt;/ul&gt;
  
          &lt;/div&gt;
  
      &lt;/div&gt;
  
      &lt;div class="content"&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>My problem is that the scroll can be a little jumpy when jumping between the Home and Contact links. Admittedly it only does this when you click on one of the buttons before the scroll has had time to catch its breath, but this particular client is very specific with how things work, and I know they will pick up on it (plus I would never knowingly want to release something with a bug, however minor).</p>
  
  <p>My question is, is there an easy way to queue the actions in jQuery so the previous action has time to stop and catch its breath before the next one starts?</p>
  
  <p>I have tried .stop() after the click function, and after the animate function. The one after the click function made it worse, and the one after the animate function broke it all together...</p>
  
  <p>Many thanks in advance!</p>
  
  <p>Kevin</p>