motion-dom 12.35.0 → 12.35.1

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/dist/cjs/index.js CHANGED
@@ -1486,7 +1486,7 @@ class JSAnimation extends WithPromise {
1486
1486
  const state = isInDelayPhase
1487
1487
  ? { done: false, value: keyframes[0] }
1488
1488
  : frameGenerator.next(elapsed);
1489
- if (mixKeyframes) {
1489
+ if (mixKeyframes && !isInDelayPhase) {
1490
1490
  state.value = mixKeyframes(state.value);
1491
1491
  }
1492
1492
  let { done } = state;
@@ -1539,16 +1539,26 @@ class JSAnimation extends WithPromise {
1539
1539
  else if (this.driver) {
1540
1540
  this.startTime = this.driver.now() - newTime / this.playbackSpeed;
1541
1541
  }
1542
- this.driver?.start(false);
1542
+ if (this.driver) {
1543
+ this.driver.start(false);
1544
+ }
1545
+ else {
1546
+ this.startTime = 0;
1547
+ this.state = "paused";
1548
+ this.holdTime = newTime;
1549
+ this.tick(newTime);
1550
+ }
1543
1551
  }
1544
1552
  get speed() {
1545
1553
  return this.playbackSpeed;
1546
1554
  }
1547
1555
  set speed(newSpeed) {
1548
- this.updateTime(time.now());
1549
1556
  const hasChanged = this.playbackSpeed !== newSpeed;
1557
+ if (hasChanged && this.driver) {
1558
+ this.updateTime(time.now());
1559
+ }
1550
1560
  this.playbackSpeed = newSpeed;
1551
- if (hasChanged) {
1561
+ if (hasChanged && this.driver) {
1552
1562
  this.time = motionUtils.millisecondsToSeconds(this.currentTime);
1553
1563
  }
1554
1564
  }
@@ -2158,9 +2168,13 @@ class NativeAnimation extends WithPromise {
2158
2168
  return motionUtils.millisecondsToSeconds(Number(this.animation.currentTime) || 0);
2159
2169
  }
2160
2170
  set time(newTime) {
2171
+ const wasFinished = this.finishedTime !== null;
2161
2172
  this.manualStartTime = null;
2162
2173
  this.finishedTime = null;
2163
2174
  this.animation.currentTime = motionUtils.secondsToMilliseconds(newTime);
2175
+ if (wasFinished) {
2176
+ this.animation.pause();
2177
+ }
2164
2178
  }
2165
2179
  /**
2166
2180
  * The playback speed of the animation.
@@ -2282,7 +2296,16 @@ class NativeAnimationExtended extends NativeAnimation {
2282
2296
  */
2283
2297
  const sampleTime = Math.max(sampleDelta, time.now() - this.startTime);
2284
2298
  const delta = motionUtils.clamp(0, sampleDelta, sampleTime - sampleDelta);
2285
- motionValue.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, sampleAnimation.sample(sampleTime).value, delta);
2299
+ const current = sampleAnimation.sample(sampleTime).value;
2300
+ /**
2301
+ * Write the estimated value to inline style so it persists
2302
+ * after cancel(), covering the async gap before the next
2303
+ * animation starts.
2304
+ */
2305
+ const { name } = this.options;
2306
+ if (element && name)
2307
+ setStyle(element, name, current);
2308
+ motionValue.setWithVelocity(sampleAnimation.sample(Math.max(0, sampleTime - delta)).value, current, delta);
2286
2309
  sampleAnimation.stop();
2287
2310
  }
2288
2311
  }