mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-02-17 12:10:49 +01:00
make the throttle timer a dict to keep track of which slider has been changed
This commit is contained in:
parent
1de4944d46
commit
6ed50ee1e9
@ -132,14 +132,15 @@ var sliders_throttle = getThrottle(250);
|
||||
* @return {(function(*): void)|*} function that takes the ms to wait and a callback to execute after the timer
|
||||
*/
|
||||
function getThrottle(ms) {
|
||||
var timer;
|
||||
var timer = {};
|
||||
|
||||
return function (callback) {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
return function (id, callback) {
|
||||
if (timer[id]) {
|
||||
clearTimeout(timer[id]);
|
||||
}
|
||||
timer = setTimeout(function () {
|
||||
timer[id] = setTimeout(function () {
|
||||
callback();
|
||||
delete timer[id];
|
||||
}, ms);
|
||||
}
|
||||
}
|
||||
@ -175,7 +176,7 @@ function addSetting(ob) {
|
||||
window["label_"+ob.id] = reflb; // Is this still needed?
|
||||
// Add event function to input
|
||||
refin.on("input", function () {
|
||||
sliders_throttle(function () {
|
||||
sliders_throttle(ob.id, function () {
|
||||
socket.send({'cmd': $(this).attr('id'), 'data': $(this).val()});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user