I am using pure javascript for vertical scroll.I need this scroll to have smooth behaviour.
function move_up(scroll_nav)
{
var container = document.getElementById(scroll_nav);
upScroll(container,'up',40,50,10);
}
function move_down(scroll_nav)
{
var container = document.getElementById(scroll_nav);
upScroll(container,'down',40,50,10);
}
function upScroll(element,direction,speed,distance,step)
{
scrollAmount = 0;
var slideTimer = setInterval(function(){
if(direction == 'up'){
element.scrollTop -= step;
} else {
element.scrollTop += step;
}
scrollAmount += step;
if(scrollAmount >= distance){
window.clearInterval(slideTimer);
}
}, speed);
}
I need an animate function similar to the one in this link but without jquery. https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_smooth_scroll_jquery
I need an animate function to be included Please provide an solution .