mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Move debouncer to App.
Debounce drag of splitter and window resize
This commit is contained in:
parent
eb91dd7a7d
commit
87dc325932
3 changed files with 28 additions and 27 deletions
|
@ -598,28 +598,6 @@ class InputWaiter {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Debouncer to stop functions from being executed multiple times in a
|
||||
* short space of time
|
||||
* https://davidwalsh.name/javascript-debounce-function
|
||||
*
|
||||
* @param {function} func - The function to be executed after the debounce time
|
||||
* @param {number} wait - The time (ms) to wait before executing the function
|
||||
* @param {array} args - Array of arguments to be passed to func
|
||||
* @returns {function}
|
||||
*/
|
||||
debounce(func, wait, args) {
|
||||
return function() {
|
||||
const context = this,
|
||||
later = function() {
|
||||
this.inputTimeout = null;
|
||||
func.apply(context, args);
|
||||
};
|
||||
clearTimeout(this.inputTimeout);
|
||||
this.inputTimeout = setTimeout(later, wait);
|
||||
}.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for input change events.
|
||||
* Debounces the input so we don't call autobake too often.
|
||||
|
@ -627,7 +605,7 @@ class InputWaiter {
|
|||
* @param {event} e
|
||||
*/
|
||||
debounceInputChange(e) {
|
||||
this.debounce(this.inputChange.bind(this), 50, [e])();
|
||||
this.app.debounce(this.inputChange, 50, "inputChange", this, [e])();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue