mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Add js debounce util
This commit is contained in:
parent
a144301085
commit
4e3e23db36
1 changed files with 11 additions and 0 deletions
11
resources/assets/js/util/debounce.js
vendored
Normal file
11
resources/assets/js/util/debounce.js
vendored
Normal file
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue