fix: wait for elapsed

This commit is contained in:
cha0s 2024-09-14 17:30:42 -05:00
parent fc96f637ff
commit 89044ab2cf

View File

@ -48,10 +48,20 @@ export default class Script {
Math: MathUtil, Math: MathUtil,
Promise: PromiseUtil, Promise: PromiseUtil,
transition, transition,
wait: (seconds) => ( wait: (seconds = 0) => (
new Promise((resolve) => { new PromiseUtil.Ticker(
setTimeout(resolve, seconds * 1000); (resolve) => {
}) if (0 === seconds) {
resolve();
}
},
(elapsed, resolve) => {
seconds -= elapsed;
if (seconds <= 0) {
resolve();
}
}
)
), ),
}; };
} }