From 4e3e23db36fe28f34c36d2d55272e86d1598b442 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 23 Oct 2023 00:15:53 -0600 Subject: [PATCH] Add js debounce util --- resources/assets/js/util/debounce.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 resources/assets/js/util/debounce.js diff --git a/resources/assets/js/util/debounce.js b/resources/assets/js/util/debounce.js new file mode 100644 index 000000000..b846d35e5 --- /dev/null +++ b/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) + } +}