소스 검색

Add js debounce util

Daniel Supernault 1 년 전
부모
커밋
4e3e23db36
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  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)
+  }
+}