|
@@ -3,14 +3,17 @@
|
|
|
* @param {Function} callback 回调函数
|
|
|
* @param {boolean} isEnd 是否停止
|
|
|
* @param {number} duration 绘制的间隔时间(默认1s)
|
|
|
+ * @returns {Function}
|
|
|
*/
|
|
|
export default function animation(callback, duration = 1000) {
|
|
|
// 判断是否为函数
|
|
|
- if(typeof callback !== 'function') throw new Error('callback is not a function');
|
|
|
+ if (typeof callback !== "function")
|
|
|
+ throw new Error("callback is not a function");
|
|
|
// 判断是否为数字
|
|
|
- if(typeof duration !== 'number') throw new Error('duration is not a number');
|
|
|
+ if (typeof duration !== "number") throw new Error("duration is not a number");
|
|
|
// 判断是否 > 16
|
|
|
- if(duration <= 16) throw new Error('duration is not a Less than or equal to 16');
|
|
|
+ if (duration <= 16)
|
|
|
+ throw new Error("duration is not a Less than or equal to 16");
|
|
|
|
|
|
let time = Date.now();
|
|
|
function _run() {
|