@xtia/timeline 1.1.10 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/internal/emitters.js +2 -1
- package/internal/timeline.js +11 -5
- package/internal/tween.js +2 -2
- package/package.json +1 -1
package/internal/emitters.js
CHANGED
|
@@ -7,7 +7,8 @@ export class Emitter {
|
|
|
7
7
|
}
|
|
8
8
|
createTransformListen(handler) {
|
|
9
9
|
let parentUnsubscribe = null;
|
|
10
|
-
const
|
|
10
|
+
const parentListen = this.onListen;
|
|
11
|
+
const { emit, listen } = createListenable(() => parentUnsubscribe = parentListen(value => {
|
|
11
12
|
handler(value, emit);
|
|
12
13
|
}), () => {
|
|
13
14
|
parentUnsubscribe();
|
package/internal/timeline.js
CHANGED
|
@@ -87,8 +87,11 @@ export class Timeline {
|
|
|
87
87
|
this._progression = null;
|
|
88
88
|
if (endAction == "loop")
|
|
89
89
|
endAction = "restart";
|
|
90
|
-
if (autoplay
|
|
91
|
-
this.play(
|
|
90
|
+
if (autoplay === true) {
|
|
91
|
+
this.play();
|
|
92
|
+
}
|
|
93
|
+
else if (typeof autoplay == "number") {
|
|
94
|
+
this.play(autoplay);
|
|
92
95
|
}
|
|
93
96
|
if (typeof endAction == "object"
|
|
94
97
|
&& "restartAt" in endAction) {
|
|
@@ -210,7 +213,10 @@ export class Timeline {
|
|
|
210
213
|
.range(0, durationMs)
|
|
211
214
|
.ease(easer)
|
|
212
215
|
.tween(this._currentTime, toPosition)
|
|
213
|
-
.apply(v =>
|
|
216
|
+
.apply(v => {
|
|
217
|
+
this.seekDirect(v);
|
|
218
|
+
this._frameEvents?.emit();
|
|
219
|
+
});
|
|
214
220
|
return seeker.end.promise();
|
|
215
221
|
}
|
|
216
222
|
seekDirect(toPosition) {
|
|
@@ -334,9 +340,9 @@ export class Timeline {
|
|
|
334
340
|
this.playWithInterval(arg ?? default_fps);
|
|
335
341
|
}
|
|
336
342
|
playWithInterval(fps) {
|
|
337
|
-
let previousTime =
|
|
343
|
+
let previousTime = performance.now();
|
|
338
344
|
const interval = setInterval(() => {
|
|
339
|
-
const newTime =
|
|
345
|
+
const newTime = performance.now();
|
|
340
346
|
const elapsed = newTime - previousTime;
|
|
341
347
|
previousTime = newTime;
|
|
342
348
|
let delta = elapsed * this.timeScale;
|
package/internal/tween.js
CHANGED
|
@@ -143,13 +143,13 @@ function tokenise(s) {
|
|
|
143
143
|
let m;
|
|
144
144
|
while ((m = tweenableTokenRegex.exec(s))) {
|
|
145
145
|
const token = m[0];
|
|
146
|
-
const prefix = s.
|
|
146
|
+
const prefix = s.substring(lastIdx, m.index); // literal before token
|
|
147
147
|
const type = getTokenType(token);
|
|
148
148
|
chunks.push({ prefix, token, type });
|
|
149
149
|
lastIdx = m.index + token.length;
|
|
150
150
|
}
|
|
151
151
|
// trailing literal after the last token – stored as a final chunk
|
|
152
|
-
const tail = s.
|
|
152
|
+
const tail = s.substring(lastIdx);
|
|
153
153
|
if (tail.length) {
|
|
154
154
|
chunks.push({ prefix: tail, token: "", type: TokenTypes.none });
|
|
155
155
|
}
|