Fix: use debounce
This commit is contained in:
parent
285f3144ca
commit
a7b73e859f
|
@ -1,4 +1,4 @@
|
||||||
/* global regExpTester */
|
/* global regExpTester debounce */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function createAppliesToLineWidget(cm) {
|
function createAppliesToLineWidget(cm) {
|
||||||
|
@ -10,7 +10,7 @@ function createAppliesToLineWidget(cm) {
|
||||||
];
|
];
|
||||||
const THROTTLE_DELAY = 400;
|
const THROTTLE_DELAY = 400;
|
||||||
let widgets = [];
|
let widgets = [];
|
||||||
let timer, fromLine, toLine, gutterStyle, isInit;
|
let fromLine, toLine, gutterStyle, isInit;
|
||||||
|
|
||||||
return {toggle};
|
return {toggle};
|
||||||
|
|
||||||
|
@ -59,8 +59,7 @@ function createAppliesToLineWidget(cm) {
|
||||||
fromLine = Math.min(fromLine, from.line);
|
fromLine = Math.min(fromLine, from.line);
|
||||||
toLine = Math.max(toLine, to.line);
|
toLine = Math.max(toLine, to.line);
|
||||||
}
|
}
|
||||||
clearTimeout(timer);
|
debounce(update, THROTTLE_DELAY);
|
||||||
timer = setTimeout(update, THROTTLE_DELAY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onOptionChange(cm, option) {
|
function onOptionChange(cm, option) {
|
||||||
|
@ -233,14 +232,12 @@ function createAppliesToLineWidget(cm) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
typeInput.value = apply.type.text;
|
typeInput.value = apply.type.text;
|
||||||
let timer;
|
|
||||||
const valueInput = $element({
|
const valueInput = $element({
|
||||||
tag: 'input',
|
tag: 'input',
|
||||||
className: 'applies-value',
|
className: 'applies-value',
|
||||||
value: apply.value.text,
|
value: apply.value.text,
|
||||||
oninput(e) {
|
oninput(e) {
|
||||||
clearTimeout(timer);
|
debounce(applyChange, THROTTLE_DELAY, apply.value, e.target.value);
|
||||||
timer = setTimeout(applyChange, THROTTLE_DELAY, apply.value, e.target.value);
|
|
||||||
},
|
},
|
||||||
onfocus: updateRegexpTest
|
onfocus: updateRegexpTest
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user