title: Run a function only when another one is finished
body: <p>I have this function and I want to add <code>.hidden</code> class only when the div had scroll to top. I know I can use <code>SetTimeout</code> but it would be random and I want to be sure that the div disappear when had scroll to top.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(".more").on("click", function() {
    $("#wait").animate({
        scrollTop: 0
      }),
      $(".more").toggleClass("nascosto"),
      $("#wait").toggleClass("hidden")
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.more {
    cursor: pointer;
    position: fixed;
    font-size: 30px;
    top: 10px;
    left: 10px;
  }
  #wait {
    font-size: 30px;
    right: 10px;
    width: 50%;
    position: fixed;
    overflow-y: scroll;
    height: 100vh;
  }
  #about {
    overflow-y: scroll;
  }
  .hidden {
    opacity: 0;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class=more&gt;click&lt;/div&gt;
  &lt;div id="wait"&gt;
    &lt;div id=about
    "&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;/div&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>