Math.easeInOutQuad=function(t, b, c, d){
t /= d /2if(t <1){return(c /2)* t * t + b
}
t--return(-c /2)*(t *(t -2)-1)+ b
}// requestAnimationFrame for Smart Animating http://goo.gl/sx5stsconst requestAnimFrame =(function(){return(
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||function(callback){
window.setTimeout(callback,1000/60)})})()/**
* Because it's so fucking difficult to detect the scrolling element, just move them all
* @param {number} amount
*/functionmove(amount){
document.documentElement.scrollTop = amount
document.body.parentNode.scrollTop = amount
document.body.scrollTop = amount
}functionposition(){return(
document.documentElement.scrollTop ||
document.body.parentNode.scrollTop ||
document.body.scrollTop
)}/**
* @param {number} to
* @param {number} duration
* @param {Function} callback
*/exportfunctionscrollTo(to, duration, callback){const start =position()const change = to - start
const increment =20let currentTime =0
duration =typeof duration ==='undefined'?500: duration
constanimateScroll=function(){// increment the time
currentTime += increment
// find the value with the quadratic in-out easing functionconst val = Math.easeInOutQuad(currentTime, start, change, duration)// move the document.bodymove(val)// do the animation unless its overif(currentTime < duration){requestAnimFrame(animateScroll)}else{if(callback &&typeof callback ==='function'){// the animation is done so lets callbackcallback()}}}animateScroll()}