wrap finish event as promise
This commit is contained in:
@@ -27,9 +27,10 @@ class MotionEngine {
|
||||
}
|
||||
|
||||
// a = {o-object, a-attributes, t-time, f-finish event, d-delay, m-mode, r-repeat,
|
||||
// rd-repeat the delay, rf-reset on finish, u-on update, s-scope}
|
||||
// rd-repeat the delay, rf-reset on finish, u-on update, s-scope, p-promise on finish}
|
||||
this.add = function (a) {
|
||||
a = Array.isArray(a) ? a : [a];
|
||||
let r = [];
|
||||
a.forEach(e => {
|
||||
if (e.t == 0){
|
||||
e.t = 1;
|
||||
@@ -37,7 +38,11 @@ class MotionEngine {
|
||||
}else{
|
||||
aq.push(e);
|
||||
}
|
||||
if (e.p && !e.f){
|
||||
r.push(new Promise( resolve=> e.f = resolve ))
|
||||
}
|
||||
});
|
||||
if (r.length) return Promise.all(r);
|
||||
};
|
||||
|
||||
this.clear = function (object, reset = false) {
|
||||
|
||||
Reference in New Issue
Block a user