Here is an example of my ancient code of smooth scrolling up, I think it will not be difficult to alter under your conditions.
var toTopButton = document.getElementById('scroll-to-top'); if (toTopButton) { Math.easeInOutQuad = function (t, b, c, d) { t /= d/2; if (t < 1) { return c/2*t*t + b } t--; return -c/2 * (t*(t-2) - 1) + b; }; var requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); }; })(); function scrollToTop() { function move(amount) { document.documentElement.scrollTop = amount; document.body.parentNode.scrollTop = amount; document.body.scrollTop = amount; } function position() { return document.documentElement.scrollTop || document.body.parentNode.scrollTop || document.body.scrollTop; } var start = position(), currentTime = 0, increment = 20; var animateScroll = function() { currentTime += increment; var val = Math.easeInOutQuad(currentTime, start, -start, 300); move(val); if (currentTime < 300) { requestAnimFrame(animateScroll); } }; animateScroll(); } toTopButton.addEventListener("click", function(e){ e.preventDefault(); scrollToTop(); }); }