Created
April 12, 2010 14:18
-
-
Save okuryu/363603 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>YUI 3 throttle function test</title> | |
</head> | |
<body> | |
<p>YUI 3 throttle function test</p> | |
<script type="text/javascript" src="http://yui.yahooapis.com/3.1.0/build/yui/yui-min.js"></script> | |
<script type="text/javascript"> | |
YUI().use('*', function(Y) { | |
// create throttled function. | |
var fn = Y.throttle(function(id) { | |
Y.log('called function ' + id); | |
}, 2000); | |
var timer1 = setTimeout(function() { | |
// ignore function. | |
fn(1); | |
clearTimeout(timer1); | |
}, 1000); | |
var timer2 = setTimeout(function() { | |
// available function. | |
fn(2); | |
clearTimeout(timer2); | |
}, 3000); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment