Skip to content

Instantly share code, notes, and snippets.

@okuryu
Created April 12, 2010 14:18
Show Gist options
  • Save okuryu/363603 to your computer and use it in GitHub Desktop.
Save okuryu/363603 to your computer and use it in GitHub Desktop.
<!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