UNPKG

@yuanjili/js-es-c

Version:

js工具包

1 lines 805 B
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.scrollTo=scrollTo,Math.easeInOutQuad=function(a,e,b,c){return(a/=c/2,1>a)?b/2*a*a+e:(a--,-b/2*(a*(a-2)-1)+e)};var requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1e3/60)}}();function move(a){document.documentElement.scrollTop=a,document.body.parentNode.scrollTop=a,document.body.scrollTop=a}function position(){return document.documentElement.scrollTop||document.body.parentNode.scrollTop||document.body.scrollTop}function scrollTo(a,b,c){var d=position(),e=0;b="undefined"==typeof b?500:b;(function f(){e+=20;var g=Math.easeInOutQuad(e,d,a-d,b);move(g),e<b?requestAnimFrame(f):c&&"function"==typeof c&&c()})()}