motion-dom 12.34.5 → 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
  }
@@ -1945,6 +1955,7 @@ function memoSupports(callback, supportsFlag) {
1945
1955
  }
1946
1956
 
1947
1957
  const supportsScrollTimeline = /* @__PURE__ */ memoSupports(() => window.ScrollTimeline !== undefined, "scrollTimeline");
1958
+ const supportsViewTimeline = /* @__PURE__ */ memoSupports(() => window.ViewTimeline !== undefined, "viewTimeline");
1948
1959
 
1949
1960
  const supportsLinearEasing = /*@__PURE__*/ memoSupports(() => {
1950
1961
  try {
@@ -2157,9 +2168,13 @@ class NativeAnimation extends WithPromise {
2157
2168
  return motionUtils.millisecondsToSeconds(Number(this.animation.currentTime) || 0);
2158
2169
  }
2159
2170
  set time(newTime) {
2171
+ const wasFinished = this.finishedTime !== null;
2160
2172
  this.manualStartTime = null;
2161
2173
  this.finishedTime = null;
2162
2174
  this.animation.currentTime = motionUtils.secondsToMilliseconds(newTime);
2175
+ if (wasFinished) {
2176
+ this.animation.pause();
2177
+ }
2163
2178
  }
2164
2179
  /**
2165
2180
  * The playback speed of the animation.
@@ -2188,13 +2203,17 @@ class NativeAnimation extends WithPromise {
2188
2203
  /**
2189
2204
  * Attaches a timeline to the animation, for instance the `ScrollTimeline`.
2190
2205
  */
2191
- attachTimeline({ timeline, observe }) {
2206
+ attachTimeline({ timeline, rangeStart, rangeEnd, observe, }) {
2192
2207
  if (this.allowFlatten) {
2193
2208
  this.animation.effect?.updateTiming({ easing: "linear" });
2194
2209
  }
2195
2210
  this.animation.onfinish = null;
2196
2211
  if (timeline && supportsScrollTimeline()) {
2197
2212
  this.animation.timeline = timeline;
2213
+ if (rangeStart)
2214
+ this.animation.rangeStart = rangeStart;
2215
+ if (rangeEnd)
2216
+ this.animation.rangeEnd = rangeEnd;
2198
2217
  return motionUtils.noop;
2199
2218
  }
2200
2219
  else {
@@ -2277,7 +2296,16 @@ class NativeAnimationExtended extends NativeAnimation {
2277
2296
  */
2278
2297
  const sampleTime = Math.max(sampleDelta, time.now() - this.startTime);
2279
2298
  const delta = motionUtils.clamp(0, sampleDelta, sampleTime - sampleDelta);
2280
- 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);
2281
2309
  sampleAnimation.stop();
2282
2310
  }
2283
2311
  }
@@ -6184,12 +6212,18 @@ function transformAxis(axis, axisTranslate, axisScale, boxScale, axisOrigin = 0.
6184
6212
  // Apply the axis delta to the final axis
6185
6213
  applyAxisDelta(axis, axisTranslate, axisScale, originPoint, boxScale);
6186
6214
  }
6215
+ function resolveAxisTranslate(value, axis) {
6216
+ if (typeof value === "string") {
6217
+ return (parseFloat(value) / 100) * (axis.max - axis.min);
6218
+ }
6219
+ return value;
6220
+ }
6187
6221
  /**
6188
6222
  * Apply a transform to a box from the latest resolved motion values.
6189
6223
  */
6190
6224
  function transformBox(box, transform) {
6191
- transformAxis(box.x, transform.x, transform.scaleX, transform.scale, transform.originX);
6192
- transformAxis(box.y, transform.y, transform.scaleY, transform.scale, transform.originY);
6225
+ transformAxis(box.x, resolveAxisTranslate(transform.x, box.x), transform.scaleX, transform.scale, transform.originX);
6226
+ transformAxis(box.y, resolveAxisTranslate(transform.y, box.y), transform.scaleY, transform.scale, transform.originY);
6193
6227
  }
6194
6228
 
6195
6229
  function measureViewportBox(instance, transformPoint) {
@@ -9723,6 +9757,7 @@ exports.supportsFlags = supportsFlags;
9723
9757
  exports.supportsLinearEasing = supportsLinearEasing;
9724
9758
  exports.supportsPartialKeyframes = supportsPartialKeyframes;
9725
9759
  exports.supportsScrollTimeline = supportsScrollTimeline;
9760
+ exports.supportsViewTimeline = supportsViewTimeline;
9726
9761
  exports.svgEffect = svgEffect;
9727
9762
  exports.sync = sync;
9728
9763
  exports.testValueType = testValueType;