Browse Source

Add js debounce util

Daniel Supernault 1 năm trước cách đây
mục cha
commit
4e3e23db36
1 tập tin đã thay đổi với 11 bổ sung0 xóa
  1. 11 0
      resources/assets/js/util/debounce.js

+ 11 - 0
resources/assets/js/util/debounce.js

@@ -0,0 +1,11 @@
+export function debounce (fn, delay) {
+  var timeoutID = null
+  return function () {
+    clearTimeout(timeoutID)
+    var args = arguments
+    var that = this
+    timeoutID = setTimeout(function () {
+      fn.apply(that, args)
+    }, delay)
+  }
+}