title: Javascript - how to animate scrollIntoView
body: <p>I was only able to get a div on click into view with the <code>scrollIntoView</code> function, and it works as it should, just the way I want it, but I wonder is there a way to somehow animate it, and make it a bit slower?</p>
  
  <p>I have tried with a suggestion from <a href="https://praveenlobo.com/blog/how-to-scroll-elements-smoothly-in-javascript-jquery-without-plugins/" rel="nofollow">here</a>:</p>
  
  <pre><code>function scroll(element, parent){
        $(parent)[0].scrollIntoView(false);
        $(parent).animate({
           scrollTop: $(parent).scrollTop() + $(element).offset().top - $(parent).offset().top,
           duration: 500,
           easing: 'swing'
         });
      }
  </code></pre>
  
  <p>But it pushes the element to far up, it is not pushing it as it is on just:</p>
  
  <pre><code>$('#drawer')[0].scrollIntoView(false);
  </code></pre>