* @param {number} t
(t)
| 95 | * @param {number} t |
| 96 | */ |
| 97 | #apply_keyframe(t) { |
| 98 | const n = Math.min(1, Math.max(0, t)) * (this.#keyframes.length - 1); |
| 99 | |
| 100 | const lower = this.#keyframes[Math.floor(n)]; |
| 101 | const upper = this.#keyframes[Math.ceil(n)]; |
| 102 | |
| 103 | let frame = lower; |
| 104 | if (lower !== upper) { |
| 105 | frame = {}; |
| 106 | |
| 107 | for (const key in lower) { |
| 108 | frame[key] = interpolate( |
| 109 | /** @type {string} */ (lower[key]), |
| 110 | /** @type {string} */ (upper[key]), |
| 111 | n % 1 |
| 112 | ); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | for (let prop in frame) { |
| 117 | // @ts-ignore |
| 118 | this.target.style[prop] = frame[prop]; |
| 119 | } |
| 120 | |
| 121 | if (this.currentTime >= this.#duration) { |
| 122 | this.currentTime = this.#duration; |
| 123 | for (let prop in frame) { |
| 124 | // @ts-ignore |
| 125 | this.target.style[prop] = null; |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | cancel() { |
| 131 | if (this.currentTime > 0 && this.currentTime < this.#duration) { |
no test coverage detected