Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zzossig/hugo-theme-zzo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/helper/throttle.js')
-rw-r--r--assets/js/helper/throttle.js12
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);
+ }
+ };
+}