-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebounce
More file actions
27 lines (12 loc) · 725 Bytes
/
debounce
File metadata and controls
27 lines (12 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<textarea></textarea>
<script>
var textfield = document.getElementsByTagName('textarea')[0];
var debounce = (callback,delay=2_000)=>{
var timer;
return ()=>{
clearTimeout(timer);
timer = setTimeout(callback,delay);
};
}//debounce
textfield.oninput = debounce(()=>console.log('!! fire in the hole !!'));
</script>