Math.easeInOutQuad=function(t,b,c,d){t/=d/2if(t<1){returnc/2*t*t+b}t--return-c/2*(t*(t-2)-1)+b}//用于智能动画的requestAnimationFramehttp://goo.gl/sx5stsvarrequestAnimFrame=(function(){returnwindow.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(callback){window.setTimeout(callback,1000/60)}})()/***因为检测滚动元素太他妈难了,把它们全部移动*@param{number}amount*/functionmove(金额,domTarget){if(domTarget&&document.querySelector(domTarget)){document.querySelector(domTarget).scrollTop=amount}elseif(document.querySelector('.base')){document.querySelector('.base').scrollTop=amount}document.documentElement.scrollTop=amountdocument.body.parentNode.scrollTop=amountdocument.body.scrollTop=amount}函数位置(domTarget){if(domTarget&&document.querySelector(domTarget)){返回document.querySelector(domTarget).scrollTop||文档.documentElement.scrollTop||文档.body.parentNode.scrollTop||document.body.scrollTop}返回document.querySelector('.base')&&document.querySelector('.base').scrollTop||文档.documentElement.scrollTop||文档.body.parentNode.scrollTop||document.body.scrollTop}/***@param{number}to*@param{number}duration*@param{Function}callback*/exportfunctionscrollTo(to,duration,callback,domTarget){conststart=position(domTarget)constchange=to-startconstincrement=20letcurrentTime=0duration=(typeof(duration)==='undefined')?500:durationvaranimateScroll=function(){//增加时间currentTime+=increment//使用二次输入输出缓动函数找到值varval=Math.easeInOutQuad(currentTime,start,change,duration)//移动document.bodymove(val,domTarget)//执行动画除非它结束if(currentTime
