标签:var als run stop top timer timers length art
var timer = { timerId : 0, timers : [], add : function(fn){ this.timers.push(fn); }, start : function(){ if(this.timerId){ return; } (function runNext(){ if(timer.timers.length > 0){ for(var i = 0; i < timer.timers.length; i++){ if(timer.timers[i]() === false){ timer.timers.splice(i,1); i--; } } timer.timerId = setTimeout(runNext,0); } })(); }, stop : function(){ clearTimeout(this.timerId); this.timerId = 0; } };
标签:var als run stop top timer timers length art
原文地址:http://www.cnblogs.com/halo-yang/p/7875371.html