Created
December 13, 2012 06:24
-
-
Save composite/4274504 to your computer and use it in GitHub Desktop.
queue function calling continuous, step friendly, without hanging, but less performance for lot of function calls...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setQueue(func){ | |
setQueue.fns.push(func); | |
if(!setQueue.isRun){setQueue.isRun=true;setQueue.invoke();} | |
} setQueue.delay=0;setQueue.fns=[]; | |
setQueue.invoke=function(){ | |
setTimeout(function(){ | |
if(!setQueue.fns.length||!setQueue.isRun){setQueue.isRun=false;return;} | |
var fn=setQueue.fns.shift(); | |
if(typeof(fn)=='function') fn(); | |
setTimeout(arguments.callee,setQueue.delay); | |
},setQueue.delay); | |
};setQueue.pause=function(){setQueue.isRun=false;} | |
setQueue.clear=function(){setQueue.fns.length=0;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment