UNPKG

chowa

Version:

UI component library based on React

34 lines (33 loc) 924 B
/** * @license chowa v1.1.3 * * Copyright (c) Chowa Techonlogies Co.,Ltd.(http://www.chowa.cn). * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function easeIn(distance, cb) { let animId = null; let retVal = 0; const animationFn = () => { let step = Math.ceil(distance / 6); if (step === 0) { step = distance; } distance -= step; retVal += step; if (typeof cb === 'function') { cb(retVal); } if (distance === 0) { window.cancelAnimationFrame(animId); } else { animId = window.requestAnimationFrame(animationFn); } }; return animId = window.requestAnimationFrame(animationFn); } exports.easeIn = easeIn;