I'm trying to modify the excellent function I found on here by @timwolla
Basically I want a non JQuery way of smooth scrolling to a div ID
This is what I'm trying but it doesn't scroll at all, the problem is I think, I need to find the position of the ID I'm trying to scroll to:
function scrollTo(element, to, duration) {
var el = document.getElementById(element);
if (duration < 0) return;
var difference = to - el.scrollTop;
var perTick = difference / duration * 10;
setTimeout(function() {
el.scrollTop = el.scrollTop + perTick;
if (el.scrollTop === to) return;
scrollTo(el, to, duration - 10);
}, 10);
}