Nothing, I think I found the answer to my question. There was a lot of search, but here it is:
<div id="elem1"><button onclick="scrollToward('elem2', 'elem1');">Scroll Down</button></div> <div id="elem2"></div> <script> //Here is my script: function animate(elem,style,unit,from,to,time,prop) { if( !elem) return; var start = new Date().getTime(), timer = setInterval(function() { var step = Math.min(1,(new Date().getTime()-start)/time); if (prop) { elem[style] = (from+step*(to-from))+unit; } else { elem.style[style] = (from+step*(to-from))+unit; } if( step == 1) clearInterval(timer); },25); elem.style[style] = from+unit; } function scrollToward(ele, from) { var target = document.getElementById(ele); from = document.getElementById(from).offsetTop; animate(document.body, "scrollTop", "", from, target.offsetTop, 1500, true); } </script>
Tested and works when you create divs in such a way as to create a scroll bar. Found the answer here .
IamGuest Nov 14 '16 at 22:43 2016-11-14 22:43
source share