update test helper

fix-each-block-duplications
Rich Harris 3 months ago
parent 2e6f2fcfab
commit 2cfbef476c

@ -38,8 +38,7 @@ class Animation {
#offset = raf.time; #offset = raf.time;
#finished = () => {}; onfinish = () => {};
#cancelled = () => {};
currentTime = 0; currentTime = 0;
startTime = 0; startTime = 0;
@ -54,21 +53,6 @@ class Animation {
this.#keyframes = keyframes; this.#keyframes = keyframes;
this.#duration = duration; this.#duration = duration;
// Promise-like semantics, but call callbacks immediately on raf.tick
this.finished = {
/** @param {() => void} callback */
then: (callback) => {
this.#finished = callback;
return {
/** @param {() => void} callback */
catch: (callback) => {
this.#cancelled = callback;
}
};
}
};
this._update(); this._update();
} }
@ -78,7 +62,7 @@ class Animation {
this.#apply_keyframe(target_frame); this.#apply_keyframe(target_frame);
if (this.currentTime >= this.#duration) { if (this.currentTime >= this.#duration) {
this.#finished(); this.onfinish();
raf.animations.delete(this); raf.animations.delete(this);
} }
} }
@ -128,7 +112,6 @@ class Animation {
this.currentTime = null; this.currentTime = null;
// @ts-ignore // @ts-ignore
this.startTime = null; this.startTime = null;
this.#cancelled();
raf.animations.delete(this); raf.animations.delete(this);
} }
} }

Loading…
Cancel
Save