Skip to content

Instantly share code, notes, and snippets.

@StuPig
Created August 28, 2013 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StuPig/6361565 to your computer and use it in GitHub Desktop.
Save StuPig/6361565 to your computer and use it in GitHub Desktop.
js方法执行频次限制(时间)
function throttle( fn, time ) {
var t = 0;
return function() {
var args = arguments, ctx = this;
clearTimeout(t);
t = setTimeout( function() {
fn.apply( ctx, args );
}, time );
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment