diff options
Diffstat (limited to 'assets/js/helper/throttle.js')
-rw-r--r-- | assets/js/helper/throttle.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/assets/js/helper/throttle.js b/assets/js/helper/throttle.js new file mode 100644 index 0000000..859d356 --- /dev/null +++ b/assets/js/helper/throttle.js @@ -0,0 +1,12 @@ +function throttle(callback, limit) { + var waiting = false; + return function () { + if (!waiting) { + callback.apply(this, arguments); + waiting = true; + setTimeout(function () { + waiting = false; + }, limit); + } + }; +} |