其他分享
首页 > 其他分享> > miniraf

miniraf

作者:互联网

miniraf

var miniraf = (function () {
	var oldTime = Date.now();

	return function (callback) {
		var currentTime = Date.now();
		if (currentTime - clock > 16) {
			oldTime = currentTime;
			callback(currentTime);
		} else {
			setTimeout(function () { return miniraf(callback); }, 0);
		}
	}
})();

export default miniraf

// 使用如下
import raf from 'miniraf'
raf(callback)

自己看的源码,仅供参考

标签:function,闭包,miniraf,currentTime,callback,var
来源: https://blog.csdn.net/qq_44002888/article/details/120429625