|
1 | 1 | # Debounce Event
|
2 | 2 |
|
3 |
| -Debounces batched browser event callback execution until the last event within a given time period. The utility returns a key upon event/callback attachment which can be later used to attach multiple callbacks to the same debounced event batch by given element, event name, and timeout. Debounced event batches can be manually detached, or will detach automatically if the callback is specified to be executed only once. |
| 3 | +Debounces batched browser event callback execution until the last event within a given time period. The utility returns a key upon initial event attachment which can be later used to add multiple callbacks to the same debounced event batch by given element, event name, and timeout. Debounced event batches can be manually detached, or will detach automatically if the callback is specified to be executed only once and there are no other callbacks left in the event batch. |
4 | 4 |
|
5 | 5 | ## Usage
|
6 | 6 |
|
@@ -43,12 +43,12 @@ require 'debounce-event'
|
43 | 43 |
|
44 | 44 | | Name | Description | Required |
|
45 | 45 | | ---- | ----------- | -------- |
|
46 |
| -| eventName | Name of the browser event to handle. | if `eventKey` not given | |
47 | 46 | | elem | DOM element to attach the event handler. | if `eventKey` not given |
|
| 47 | +| eventName | Name of the browser event to handle. | if `eventKey` not given | |
48 | 48 | | done | Callback to execute on the debounced event. | always |
|
49 |
| -| timeout | Timeout (ms) at which to debounce the event before executing the callback. | always | |
50 |
| -| once | True if the callback should execute only once. If the event is the only event in its group, its handler will be detached after the callback executes. Default is `false`. | no | |
51 |
| -| eventKey | Previously returned key of an event group to add this callback. If this parameter is specified, `eventName` and `elem` are not used since an event group uses a common event handler. | no | |
| 49 | +| timeout | Timeout (ms) at which to debounce the event callback. | always | |
| 50 | +| once | True if the callback should execute only once. If the callback is the only one in its batch, its handler will be detached after the callback executes. Default is `false`. | no | |
| 51 | +| eventKey | Previously returned key of an event batch to add this callback. If this parameter is specified, `eventName` and `elem` are not used since an event batch uses a common event handler. | no | |
52 | 52 |
|
53 | 53 | #### Example
|
54 | 54 |
|
@@ -84,7 +84,7 @@ var eventKey2 = DebounceEvent.attach({
|
84 | 84 | timeout: 300
|
85 | 85 | })
|
86 | 86 |
|
87 |
| -// Manually detach the given event group |
| 87 | +// Manually detach the given event batch |
88 | 88 | DebounceEvent.detach(eventKey2)
|
89 | 89 | ```
|
90 | 90 |
|
|
0 commit comments