motion-dom 12.29.2 → 12.30.0

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.
@@ -2133,7 +2133,8 @@
2133
2133
  * while deferring the commit until the next animation frame.
2134
2134
  */
2135
2135
  commitStyles() {
2136
- if (!this.isPseudoElement) {
2136
+ const element = this.options?.element;
2137
+ if (!this.isPseudoElement && element?.isConnected) {
2137
2138
  this.animation.commitStyles?.();
2138
2139
  }
2139
2140
  }
@@ -2834,7 +2835,8 @@
2834
2835
  }
2835
2836
  }
2836
2837
  if (motionUtils.MotionGlobalConfig.instantAnimations ||
2837
- motionUtils.MotionGlobalConfig.skipAnimations) {
2838
+ motionUtils.MotionGlobalConfig.skipAnimations ||
2839
+ element?.shouldSkipAnimations) {
2838
2840
  shouldSkip = true;
2839
2841
  makeAnimationInstant(options);
2840
2842
  options.delay = 0;
@@ -5378,7 +5380,7 @@
5378
5380
  scrapeMotionValuesFromProps(_props, _prevProps, _visualElement) {
5379
5381
  return {};
5380
5382
  }
5381
- constructor({ parent, props, presenceContext, reducedMotionConfig, blockInitialAnimation, visualState, }, options = {}) {
5383
+ constructor({ parent, props, presenceContext, reducedMotionConfig, skipAnimations, blockInitialAnimation, visualState, }, options = {}) {
5382
5384
  /**
5383
5385
  * A reference to the current underlying Instance, e.g. a HTMLElement
5384
5386
  * or Three.Mesh etc.
@@ -5401,6 +5403,11 @@
5401
5403
  * like it could be set globally.
5402
5404
  */
5403
5405
  this.shouldReduceMotion = null;
5406
+ /**
5407
+ * Decides whether animations should be skipped for this VisualElement.
5408
+ * Useful for E2E tests and visual regression testing.
5409
+ */
5410
+ this.shouldSkipAnimations = false;
5404
5411
  /**
5405
5412
  * A map of all motion values attached to this visual element. Motion
5406
5413
  * values are source of truth for any given animated value. A motion
@@ -5458,6 +5465,7 @@
5458
5465
  this.presenceContext = presenceContext;
5459
5466
  this.depth = parent ? parent.depth + 1 : 0;
5460
5467
  this.reducedMotionConfig = reducedMotionConfig;
5468
+ this.skipAnimationsConfig = skipAnimations;
5461
5469
  this.options = options;
5462
5470
  this.blockInitialAnimation = Boolean(blockInitialAnimation);
5463
5471
  this.isControllingVariants = isControllingVariants(props);
@@ -5514,6 +5522,10 @@
5514
5522
  {
5515
5523
  motionUtils.warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
5516
5524
  }
5525
+ /**
5526
+ * Set whether animations should be skipped based on the config.
5527
+ */
5528
+ this.shouldSkipAnimations = this.skipAnimationsConfig ?? false;
5517
5529
  this.parent?.addChild(this);
5518
5530
  this.update(this.props, this.presenceContext);
5519
5531
  }
@@ -9286,6 +9298,11 @@
9286
9298
  if (!visualElement.current) {
9287
9299
  visualElement.mount(element);
9288
9300
  }
9301
+ else if (!visualElement.projection.instance) {
9302
+ // Mount projection if VisualElement is already mounted but projection isn't
9303
+ // This happens when animate() was called before animateLayout()
9304
+ visualElement.projection.mount(element);
9305
+ }
9289
9306
  if (!existing) {
9290
9307
  visualElementStore.set(element, visualElement);
9291
9308
  }