Created
February 3, 2014 07:26
-
-
Save lkaczanowski/8780001 to your computer and use it in GitHub Desktop.
JQuery Debounce
This file contains hidden or 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 ($) { | |
| 'use strict'; | |
| $.debounce = function (delay, fn) { | |
| var timer = null; | |
| return function () { | |
| var context = this, args = arguments; | |
| clearTimeout(timer); | |
| timer = setTimeout(function () { | |
| fn.apply(context, args); | |
| }, delay); | |
| }; | |
| }; | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment