improve throttle function
This commit is contained in:
parent
0688cba0b4
commit
1b65c36743
@ -22,7 +22,7 @@ export function throttle(func, delay, options = {}) {
|
|||||||
if (leadingExec && leading) {
|
if (leadingExec && leading) {
|
||||||
execute();
|
execute();
|
||||||
leadingExec = false;
|
leadingExec = false;
|
||||||
const nextExecDelay = elapsed < delay ? delay - elapsed : 0;
|
const nextExecDelay = elapsed < delay ? delay - elapsed : delay;
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
leadingExec = true;
|
leadingExec = true;
|
||||||
}, nextExecDelay);
|
}, nextExecDelay);
|
||||||
|
Loading…
Reference in New Issue
Block a user