js关卡函数,throat函数实现,定时运行函数
2018-06-30 12:17 muamaker 阅读(419) 评论(0) 编辑 收藏 举报function throat(callback,num){ var timer = null; callback = callback || function(){}; return function(){ if(!timer){ var that = this; var arg = arguments; timer = setTimeout(function(){ callback.apply(that,arg); timer = null; },num); } } } var throats = throat(function(e){ console.log(e.screenX,e.screenY); },1000); window.onmousemove = function(e){ throats(e); };