6 Star 10 Fork 0

Gitee 极速下载/dojo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/dojo/dojo
克隆/下载
throttle.js 804 Bytes
一键复制 编辑 原始数据 按行查看 历史
define([], function(){
// module:
// dojo/throttle
// summary:
// This module provide a throttler
return function(cb, wait){
// summary:
// Create a function that will only execute once per `wait` periods.
// description:
// Create a function that will only execute once per `wait` periods
// from last execution when called repeatedly. Useful for preventing excessive
// calculations in rapidly firing events, such as window.resize, node.mousemove
// and so on.
// cb: Function
// The callback to fire.
// wait: Integer
// time to delay before allowing cb to call again.
var canrun = true;
return function(){
if(!canrun){
return;
}
canrun = false;
cb.apply(this, arguments);
setTimeout(function(){
canrun = true;
}, wait);
};
};
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mirrors/dojo.git
[email protected]:mirrors/dojo.git
mirrors
dojo
dojo
master

搜索帮助