title: Scroll button behavior
body: <p>The button scrolls past the content I want to be shown.
  I want the &quot;About Us&quot; section to be showed to the display of user (100vh), but it just scrolls past that.</p>
  <p>Here's the code:</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>function smoothScroll(target, duration) {
    var target = document.querySelector(target);
    var targetPosition = target.getBoundingClientRect().top;
    var startPosition = window.pageYOffset;
    var distance = targetPosition - startPosition;
    var startTime = null;
  
    function animation(currentTime) {
      if (startTime === null) startTime = currentTime;
      var timeElapsed = currentTime - startTime;
      var run = ease(timeElapsed, startPosition, distance, duration);
      window.scrollTo(0, run);
      if (timeElapsed &lt; duration) requestAnimationFrame(animation);
    }
  
    function ease(t, b, c, d) {
      t /= d / 2;
      if (t &lt; 1) return (c / 2) * t * t + b;
      t--;
      return (-c / 2) * (t * (t - 2) - 1) + b;
    }
    requestAnimationFrame(animation);
  }
  
  var btn = document.querySelector(".btn");
  btn.addEventListener("click", function () {
    smoothScroll(".text-slider", 600);
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.hero {
    display: flex;
    width: 90%;
    margin: auto;
    height: 100vh;
    min-height: 100vh;
    align-items: center;
    text-align: center;
    background-image: url(/img/pexels-tranmautritam-326501.jpg);
    background-size: cover;
    background-attachment: fixed;
    justify-content: center;
  }
  
  .introduction {
    flex: 1;
    height: 30%;
  }
  
  .welcometxt h1 {
    font-size: 17px;
    color: white;
    font-weight: 100;
    letter-spacing: 12px;
  }
  
  .intro-text h1 {
    font-size: 44px;
    font-weight: 700;
    color: white;
    /* background: linear-gradient(to left, rgb(184, 184, 184), #ffffff); */
    /* -webkit-background-clip: text;
      -webkit-text-fill-color: transparent; */
  }
  
  .intro-text p {
    font-size: 18px;
    margin-top: 5px;
    color: white;
  }
  
  .cta {
    padding: 50px 0px 0px 0px;
  }
  
  .btn {
    background-color: white;
    width: 150px;
    height: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 1px;
    color: black;
    border: none;
    border-radius: 40px;
    transition: all 0.6s ease;
    box-shadow: 5px 7px 18px rgb(0, 0, 0, 0.4);
  }
  
  .btn:hover {
    background-color: black;
    color: white;
    box-shadow: 5px 7px 18px rgb(0, 0, 0, 0.8);
  }
  
  
  .text-slider {
    width: 70%;
    height: 90vh;
    margin: 100px auto;
    position: relative;
    text-align: center;
    align-items: center;
  }
  
  .carousel {
    height: 70vh;
    overflow: hidden;
  }
  
  .slider {
    height: 100%;
    display: flex;
    width: 400%;
    transition: all 0.3s;
  }
  
  .slider p {
    width: 70%;
    font-size: 17px;
  }
  
  .slider section {
    flex-basis: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .controls .arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
  }
  
  .controls .arrow i {
    font-size: 60px;
  }
  
  .arrow.left {
    left: 10px;
  }
  
  .arrow.right {
    right: 10px;
  }
  
  .nextpage-arrow i{
    font-size: 60px;
    cursor: pointer;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section class="hero"&gt;
          &lt;div class="introduction"&gt;
              &lt;div class="welcometxt"&gt;
                  &lt;h1&gt;
                      WELLCOME
                  &lt;/h1&gt;
              &lt;/div&gt;
              &lt;div class="intro-text"&gt;
                  &lt;h1&gt;Optimal Solution for Your Product&lt;/h1&gt;
                  &lt;p&gt;
                      Ensuring optimal solution for your
                      Quality Management.
                  &lt;/p&gt;
              &lt;/div&gt;
              &lt;div class="cta"&gt;
                  &lt;button class="btn"&gt;Click for more&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/section&gt;
  
      &lt;div class="text-slider" id="text-slider"&gt;
          &lt;h1&gt;About Us&lt;/h1&gt;
          &lt;div class="carousel"&gt;
              &lt;div class="slider"&gt;
                  &lt;section&gt;
                      &lt;p&gt;Lorem ipsum dolor, sit amet consectetur adipisicing elit. Aliquam, fugiat.&lt;/p&gt;
                  &lt;/section&gt;
                  &lt;section&gt;
                      &lt;p&gt;Lorem ipsum, dolor sit amet consectetur adipisicing elit. Repellat, commodi?&lt;/p&gt;
                  &lt;/section&gt;
                  &lt;section&gt;
                      &lt;p&gt;Lorem ipsum dolor, sit amet consectetur adipisicing elit. Eligendi, velit.&lt;/p&gt;
                  &lt;/section&gt;
                  &lt;section&gt;
                      &lt;p&gt;Lorem ipsum dolor sit amet consectetur adipisicing elit. Quaerat, aperiam.&lt;/p&gt;
                  &lt;/section&gt;
              &lt;/div&gt;
              &lt;div class="controls"&gt;
                  &lt;span class="arrow left"&gt;
                      &lt;i class="material-icons"&gt;
                          keyboard_arrow_left
                      &lt;/i&gt;
                  &lt;/span&gt;
                  &lt;span class="arrow right"&gt;
                      &lt;i class="material-icons"&gt;
                          keyboard_arrow_right
                      &lt;/i&gt;
                  &lt;/span&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="nextpage-arrow"&gt;
              &lt;span class="text-slider-btn"&gt;
                  &lt;i class="material-icons"&gt;
                      keyboard_arrow_down
                  &lt;/i&gt;
              &lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>As shown in the picture, it goes past &quot;About Us&quot; h1.
  I want the page to stop at &quot;About Us&quot;, and not go past it.
  If you need more code, or more explanation please comment and I'll try my best!
  Thank you in advance.</p>
  <p><a href="https://i.stack.imgur.com/scTq9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/scTq9.png" alt="enter image description here" /></a></p>
  <p>UPDATE (GIF):
  <a href="https://i.stack.imgur.com/8cRVD.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8cRVD.gif" alt="enter image description here" /></a></p>