framer-motion 9.0.2 → 9.0.3

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.
Files changed (76) hide show
  1. package/dist/cjs/index.js +3344 -3260
  2. package/dist/es/animation/hooks/use-animated-state.mjs +3 -3
  3. package/dist/es/animation/index.mjs +3 -5
  4. package/dist/es/animation/legacy-popmotion/index.mjs +6 -2
  5. package/dist/es/animation/legacy-popmotion/inertia.mjs +4 -5
  6. package/dist/es/components/AnimatePresence/use-presence.mjs +0 -1
  7. package/dist/es/events/add-dom-event.mjs +6 -0
  8. package/dist/es/events/add-pointer-event.mjs +8 -0
  9. package/dist/es/events/use-dom-event.mjs +2 -5
  10. package/dist/es/gestures/drag/VisualElementDragControls.mjs +31 -30
  11. package/dist/es/gestures/drag/index.mjs +27 -0
  12. package/dist/es/gestures/focus.mjs +42 -0
  13. package/dist/es/gestures/hover.mjs +32 -0
  14. package/dist/es/gestures/{PanSession.mjs → pan/PanSession.mjs} +8 -8
  15. package/dist/es/gestures/pan/index.mjs +38 -0
  16. package/dist/es/gestures/press.mjs +109 -0
  17. package/dist/es/index.mjs +1 -1
  18. package/dist/es/motion/features/Feature.mjs +9 -0
  19. package/dist/es/motion/features/animation/exit.mjs +32 -0
  20. package/dist/es/motion/features/animation/index.mjs +38 -0
  21. package/dist/es/motion/features/animations.mjs +8 -37
  22. package/dist/es/motion/features/definitions.mjs +17 -23
  23. package/dist/es/motion/features/drag.mjs +12 -5
  24. package/dist/es/motion/features/gestures.mjs +16 -9
  25. package/dist/es/motion/features/layout/MeasureLayout.mjs +5 -5
  26. package/dist/es/motion/features/layout.mjs +11 -0
  27. package/dist/es/motion/features/load-features.mjs +4 -6
  28. package/dist/es/motion/features/viewport/index.mjs +96 -0
  29. package/dist/es/motion/index.mjs +12 -13
  30. package/dist/es/motion/utils/use-visual-element.mjs +8 -2
  31. package/dist/es/projection/geometry/delta-apply.mjs +9 -2
  32. package/dist/es/projection/geometry/delta-calc.mjs +2 -2
  33. package/dist/es/projection/geometry/delta-remove.mjs +2 -2
  34. package/dist/es/projection/node/DocumentProjectionNode.mjs +1 -1
  35. package/dist/es/projection/node/create-projection-node.mjs +65 -57
  36. package/dist/es/projection/node/group.mjs +5 -3
  37. package/dist/es/projection/shared/stack.mjs +7 -5
  38. package/dist/es/render/VisualElement.mjs +68 -47
  39. package/dist/es/render/dom/DOMVisualElement.mjs +1 -2
  40. package/dist/es/render/dom/features-max.mjs +2 -4
  41. package/dist/es/render/dom/motion.mjs +5 -6
  42. package/dist/es/render/dom/utils/create-config.mjs +1 -2
  43. package/dist/es/render/dom/value-types/animatable-none.mjs +3 -2
  44. package/dist/es/render/svg/SVGVisualElement.mjs +2 -2
  45. package/dist/es/render/utils/animation-state.mjs +6 -2
  46. package/dist/es/render/utils/animation.mjs +4 -4
  47. package/dist/es/render/utils/motion-values.mjs +1 -1
  48. package/dist/es/render/utils/setters.mjs +14 -9
  49. package/dist/es/value/index.mjs +1 -1
  50. package/dist/es/value/utils/is-motion-value.mjs +1 -1
  51. package/dist/framer-motion.dev.js +3341 -3257
  52. package/dist/framer-motion.js +1 -1
  53. package/dist/index.d.ts +85 -77
  54. package/dist/projection.dev.js +217 -177
  55. package/dist/size-rollup-dom-animation-assets.js +1 -1
  56. package/dist/size-rollup-dom-animation-m.js +1 -1
  57. package/dist/size-rollup-dom-animation.js +1 -1
  58. package/dist/size-rollup-dom-max-assets.js +1 -1
  59. package/dist/size-rollup-dom-max.js +1 -1
  60. package/dist/size-rollup-m.js +1 -1
  61. package/dist/size-rollup-motion.js +1 -1
  62. package/dist/size-webpack-dom-animation.js +1 -1
  63. package/dist/size-webpack-dom-max.js +1 -1
  64. package/dist/size-webpack-m.js +1 -1
  65. package/dist/three-entry.d.ts +74 -38
  66. package/package.json +8 -8
  67. package/dist/es/events/use-pointer-event.mjs +0 -11
  68. package/dist/es/gestures/drag/use-drag.mjs +0 -20
  69. package/dist/es/gestures/use-focus-gesture.mjs +0 -37
  70. package/dist/es/gestures/use-hover-gesture.mjs +0 -32
  71. package/dist/es/gestures/use-pan-gesture.mjs +0 -46
  72. package/dist/es/gestures/use-tap-gesture.mjs +0 -115
  73. package/dist/es/motion/features/layout/index.mjs +0 -7
  74. package/dist/es/motion/features/viewport/use-viewport.mjs +0 -97
  75. package/dist/es/motion/utils/VisualElementHandler.mjs +0 -19
  76. package/dist/es/motion/utils/make-renderless-component.mjs +0 -6
@@ -153,7 +153,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
153
153
  }
154
154
  notifyListeners(name, ...args) {
155
155
  const subscriptionManager = this.eventHandlers.get(name);
156
- subscriptionManager === null || subscriptionManager === void 0 ? void 0 : subscriptionManager.notify(...args);
156
+ subscriptionManager && subscriptionManager.notify(...args);
157
157
  }
158
158
  hasListeners(name) {
159
159
  return this.eventHandlers.has(name);
@@ -165,7 +165,6 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
165
165
  * Lifecycles
166
166
  */
167
167
  mount(instance, isLayoutDirty = false) {
168
- var _a;
169
168
  if (this.instance)
170
169
  return;
171
170
  this.isSVG =
@@ -176,7 +175,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
176
175
  visualElement.mount(instance);
177
176
  }
178
177
  this.root.nodes.add(this);
179
- (_a = this.parent) === null || _a === void 0 ? void 0 : _a.children.add(this);
178
+ this.parent && this.parent.children.add(this);
180
179
  this.elementId && this.root.potentialNodes.delete(this.elementId);
181
180
  if (isLayoutDirty && (layout || layoutId)) {
182
181
  this.isLayoutDirty = true;
@@ -202,14 +201,15 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
202
201
  visualElement &&
203
202
  (layoutId || layout)) {
204
203
  this.addEventListener("didUpdate", ({ delta, hasLayoutChanged, hasRelativeTargetChanged, layout: newLayout, }) => {
205
- var _a, _b, _c, _d, _e;
206
204
  if (this.isTreeAnimationBlocked()) {
207
205
  this.target = undefined;
208
206
  this.relativeTarget = undefined;
209
207
  return;
210
208
  }
211
209
  // TODO: Check here if an animation exists
212
- const layoutTransition = (_b = (_a = this.options.transition) !== null && _a !== void 0 ? _a : visualElement.getDefaultTransition()) !== null && _b !== void 0 ? _b : defaultLayoutTransition;
210
+ const layoutTransition = this.options.transition ||
211
+ visualElement.getDefaultTransition() ||
212
+ defaultLayoutTransition;
213
213
  const { onLayoutAnimationStart, onLayoutAnimationComplete, } = visualElement.getProps();
214
214
  /**
215
215
  * The target layout of the element might stay the same,
@@ -225,7 +225,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
225
225
  */
226
226
  const hasOnlyRelativeTargetChanged = !hasLayoutChanged && hasRelativeTargetChanged;
227
227
  if (this.options.layoutRoot ||
228
- ((_c = this.resumeFrom) === null || _c === void 0 ? void 0 : _c.instance) ||
228
+ (this.resumeFrom && this.resumeFrom.instance) ||
229
229
  hasOnlyRelativeTargetChanged ||
230
230
  (hasLayoutChanged &&
231
231
  (targetChanged || !this.currentAnimation))) {
@@ -256,18 +256,20 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
256
256
  this.animationProgress === 0) {
257
257
  finishAnimation(this);
258
258
  }
259
- this.isLead() && ((_e = (_d = this.options).onExitComplete) === null || _e === void 0 ? void 0 : _e.call(_d));
259
+ if (this.isLead() && this.options.onExitComplete) {
260
+ this.options.onExitComplete();
261
+ }
260
262
  }
261
263
  this.targetLayout = newLayout;
262
264
  });
263
265
  }
264
266
  }
265
267
  unmount() {
266
- var _a, _b;
267
268
  this.options.layoutId && this.willUpdate();
268
269
  this.root.nodes.remove(this);
269
- (_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.remove(this);
270
- (_b = this.parent) === null || _b === void 0 ? void 0 : _b.children.delete(this);
270
+ const stack = this.getStack();
271
+ stack && stack.remove(this);
272
+ this.parent && this.parent.children.delete(this);
271
273
  this.instance = undefined;
272
274
  cancelSync.preRender(this.updateProjection);
273
275
  }
@@ -282,28 +284,25 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
282
284
  return this.updateManuallyBlocked || this.updateBlockedByResize;
283
285
  }
284
286
  isTreeAnimationBlocked() {
285
- var _a;
286
287
  return (this.isAnimationBlocked ||
287
- ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isTreeAnimationBlocked()) ||
288
+ (this.parent && this.parent.isTreeAnimationBlocked()) ||
288
289
  false);
289
290
  }
290
291
  // Note: currently only running on root node
291
292
  startUpdate() {
292
- var _a;
293
293
  if (this.isUpdateBlocked())
294
294
  return;
295
295
  this.isUpdating = true;
296
- (_a = this.nodes) === null || _a === void 0 ? void 0 : _a.forEach(resetRotation);
296
+ this.nodes && this.nodes.forEach(resetRotation);
297
297
  this.animationId++;
298
298
  }
299
299
  getTransformTemplate() {
300
- var _a;
301
- return (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.getProps().transformTemplate;
300
+ const { visualElement } = this.options;
301
+ return visualElement && visualElement.getProps().transformTemplate;
302
302
  }
303
303
  willUpdate(shouldNotifyListeners = true) {
304
- var _a, _b, _c;
305
304
  if (this.root.isUpdateBlocked()) {
306
- (_b = (_a = this.options).onExitComplete) === null || _b === void 0 ? void 0 : _b.call(_a);
305
+ this.options.onExitComplete && this.options.onExitComplete();
307
306
  return;
308
307
  }
309
308
  !this.root.isUpdating && this.root.startUpdate();
@@ -321,7 +320,10 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
321
320
  const { layoutId, layout } = this.options;
322
321
  if (layoutId === undefined && !layout)
323
322
  return;
324
- this.prevTransformTemplateValue = (_c = this.getTransformTemplate()) === null || _c === void 0 ? void 0 : _c(this.latestValues, "");
323
+ const transformTemplate = this.getTransformTemplate();
324
+ this.prevTransformTemplateValue = transformTemplate
325
+ ? transformTemplate(this.latestValues, "")
326
+ : undefined;
325
327
  this.updateSnapshot();
326
328
  shouldNotifyListeners && this.notifyListeners("willUpdate");
327
329
  }
@@ -401,7 +403,6 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
401
403
  this.snapshot = this.measure();
402
404
  }
403
405
  updateLayout() {
404
- var _a;
405
406
  if (!this.instance)
406
407
  return;
407
408
  // TODO: Incorporate into a forwarded scroll offset
@@ -429,7 +430,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
429
430
  this.isLayoutDirty = false;
430
431
  this.projectionDelta = undefined;
431
432
  this.notifyListeners("measure", this.layout.layoutBox);
432
- (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.notify("LayoutMeasure", this.layout.layoutBox, prevLayout === null || prevLayout === void 0 ? void 0 : prevLayout.layoutBox);
433
+ const { visualElement } = this.options;
434
+ visualElement &&
435
+ visualElement.notify("LayoutMeasure", this.layout.layoutBox, prevLayout ? prevLayout.layoutBox : undefined);
433
436
  }
434
437
  updateScroll(phase = "measure") {
435
438
  let needsMeasurement = Boolean(this.options.layoutScroll && this.instance);
@@ -448,12 +451,14 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
448
451
  }
449
452
  }
450
453
  resetTransform() {
451
- var _a;
452
454
  if (!resetTransform)
453
455
  return;
454
456
  const isResetRequested = this.isLayoutDirty || this.shouldResetTransform;
455
457
  const hasProjection = this.projectionDelta && !isDeltaZero(this.projectionDelta);
456
- const transformTemplateValue = (_a = this.getTransformTemplate()) === null || _a === void 0 ? void 0 : _a(this.latestValues, "");
458
+ const transformTemplate = this.getTransformTemplate();
459
+ const transformTemplateValue = transformTemplate
460
+ ? transformTemplate(this.latestValues, "")
461
+ : undefined;
457
462
  const transformTemplateHasChanged = transformTemplateValue !== this.prevTransformTemplateValue;
458
463
  if (isResetRequested &&
459
464
  (hasProjection ||
@@ -554,7 +559,6 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
554
559
  return withTransforms;
555
560
  }
556
561
  removeTransform(box) {
557
- var _a;
558
562
  const boxWithoutTransform = createBox();
559
563
  copyBoxInto(boxWithoutTransform, box);
560
564
  for (let i = 0; i < this.path.length; i++) {
@@ -567,7 +571,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
567
571
  const sourceBox = createBox();
568
572
  const nodeBox = node.measurePageBox();
569
573
  copyBoxInto(sourceBox, nodeBox);
570
- removeBoxTransforms(boxWithoutTransform, node.latestValues, (_a = node.snapshot) === null || _a === void 0 ? void 0 : _a.layoutBox, sourceBox);
574
+ removeBoxTransforms(boxWithoutTransform, node.latestValues, node.snapshot ? node.snapshot.layoutBox : undefined, sourceBox);
571
575
  }
572
576
  if (hasTransform(this.latestValues)) {
573
577
  removeBoxTransforms(boxWithoutTransform, this.latestValues);
@@ -602,7 +606,6 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
602
606
  * Frame calculations
603
607
  */
604
608
  resolveTargetDelta() {
605
- var _a;
606
609
  /**
607
610
  * Once the dirty status of nodes has been spread through the tree, we also
608
611
  * need to check if we have a shared node of a different depth that has itself
@@ -661,7 +664,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
661
664
  */
662
665
  if (this.relativeTarget &&
663
666
  this.relativeTargetOrigin &&
664
- ((_a = this.relativeParent) === null || _a === void 0 ? void 0 : _a.target)) {
667
+ this.relativeParent &&
668
+ this.relativeParent.target) {
665
669
  calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target);
666
670
  /**
667
671
  * If we've only got a targetDelta, resolve it into a target
@@ -722,7 +726,6 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
722
726
  }
723
727
  }
724
728
  calcProjection() {
725
- var _a;
726
729
  const { isProjectionDirty, isTransformDirty } = this;
727
730
  this.isProjectionDirty = this.isTransformDirty = false;
728
731
  const lead = this.getLead();
@@ -739,7 +742,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
739
742
  * If this section of the tree isn't animating we can
740
743
  * delete our target sources for the following frame.
741
744
  */
742
- this.isTreeAnimating = Boolean(((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isTreeAnimating) ||
745
+ this.isTreeAnimating = Boolean((this.parent && this.parent.isTreeAnimating) ||
743
746
  this.currentAnimation ||
744
747
  this.pendingAnimation);
745
748
  if (!this.isTreeAnimating) {
@@ -795,17 +798,20 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
795
798
  // TODO: Schedule render
796
799
  }
797
800
  scheduleRender(notifyAll = true) {
798
- var _a, _b, _c;
799
- (_b = (_a = this.options).scheduleRender) === null || _b === void 0 ? void 0 : _b.call(_a);
800
- notifyAll && ((_c = this.getStack()) === null || _c === void 0 ? void 0 : _c.scheduleRender());
801
+ this.options.scheduleRender && this.options.scheduleRender();
802
+ if (notifyAll) {
803
+ const stack = this.getStack();
804
+ stack && stack.scheduleRender();
805
+ }
801
806
  if (this.resumingFrom && !this.resumingFrom.instance) {
802
807
  this.resumingFrom = undefined;
803
808
  }
804
809
  }
805
810
  setAnimationOrigin(delta, hasOnlyRelativeTargetChanged = false) {
806
- var _a, _b;
807
811
  const snapshot = this.snapshot;
808
- const snapshotLatestValues = (snapshot === null || snapshot === void 0 ? void 0 : snapshot.latestValues) || {};
812
+ const snapshotLatestValues = snapshot
813
+ ? snapshot.latestValues
814
+ : {};
809
815
  const mixedValues = { ...this.latestValues };
810
816
  const targetDelta = createDelta();
811
817
  if (!this.relativeParent ||
@@ -814,15 +820,17 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
814
820
  }
815
821
  this.attemptToResolveRelativeTarget = !hasOnlyRelativeTargetChanged;
816
822
  const relativeLayout = createBox();
817
- const isSharedLayoutAnimation = (snapshot === null || snapshot === void 0 ? void 0 : snapshot.source) !== ((_a = this.layout) === null || _a === void 0 ? void 0 : _a.source);
818
- const isOnlyMember = (((_b = this.getStack()) === null || _b === void 0 ? void 0 : _b.members.length) || 0) <= 1;
823
+ const snapshotSource = snapshot ? snapshot.source : undefined;
824
+ const layoutSource = this.layout ? this.layout.source : undefined;
825
+ const isSharedLayoutAnimation = snapshotSource !== layoutSource;
826
+ const stack = this.getStack();
827
+ const isOnlyMember = !stack || stack.members.length <= 1;
819
828
  const shouldCrossfadeOpacity = Boolean(isSharedLayoutAnimation &&
820
829
  !isOnlyMember &&
821
830
  this.options.crossfade === true &&
822
831
  !this.path.some(hasOpacityCrossfade));
823
832
  this.animationProgress = 0;
824
833
  this.mixTargetDelta = (latest) => {
825
- var _a;
826
834
  const progress = latest / 1000;
827
835
  mixAxisDelta(targetDelta.x, delta.x, progress);
828
836
  mixAxisDelta(targetDelta.y, delta.y, progress);
@@ -830,7 +838,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
830
838
  if (this.relativeTarget &&
831
839
  this.relativeTargetOrigin &&
832
840
  this.layout &&
833
- ((_a = this.relativeParent) === null || _a === void 0 ? void 0 : _a.layout)) {
841
+ this.relativeParent &&
842
+ this.relativeParent.layout) {
834
843
  calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
835
844
  mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
836
845
  }
@@ -845,11 +854,10 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
845
854
  this.mixTargetDelta(this.options.layoutRoot ? 1000 : 0);
846
855
  }
847
856
  startAnimation(options) {
848
- var _a, _b;
849
857
  this.notifyListeners("animationStart");
850
- (_a = this.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop();
851
- if (this.resumingFrom) {
852
- (_b = this.resumingFrom.currentAnimation) === null || _b === void 0 ? void 0 : _b.stop();
858
+ this.currentAnimation && this.currentAnimation.stop();
859
+ if (this.resumingFrom && this.resumingFrom.currentAnimation) {
860
+ this.resumingFrom.currentAnimation.stop();
853
861
  }
854
862
  if (this.pendingAnimation) {
855
863
  cancelSync.update(this.pendingAnimation);
@@ -865,13 +873,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
865
873
  this.currentAnimation = animate(0, animationTarget, {
866
874
  ...options,
867
875
  onUpdate: (latest) => {
868
- var _a;
869
876
  this.mixTargetDelta(latest);
870
- (_a = options.onUpdate) === null || _a === void 0 ? void 0 : _a.call(options, latest);
877
+ options.onUpdate && options.onUpdate(latest);
871
878
  },
872
879
  onComplete: () => {
873
- var _a;
874
- (_a = options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options);
880
+ options.onComplete && options.onComplete();
875
881
  this.completeAnimation();
876
882
  },
877
883
  });
@@ -882,12 +888,12 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
882
888
  });
883
889
  }
884
890
  completeAnimation() {
885
- var _a;
886
891
  if (this.resumingFrom) {
887
892
  this.resumingFrom.currentAnimation = undefined;
888
893
  this.resumingFrom.preserveOpacity = undefined;
889
894
  }
890
- (_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.exitAnimationComplete();
895
+ const stack = this.getStack();
896
+ stack && stack.exitAnimationComplete();
891
897
  this.resumingFrom =
892
898
  this.currentAnimation =
893
899
  this.animationValues =
@@ -895,9 +901,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
895
901
  this.notifyListeners("animationComplete");
896
902
  }
897
903
  finishAnimation() {
898
- var _a;
899
904
  if (this.currentAnimation) {
900
- (_a = this.mixTargetDelta) === null || _a === void 0 ? void 0 : _a.call(this, animationTarget);
905
+ this.mixTargetDelta && this.mixTargetDelta(animationTarget);
901
906
  this.currentAnimation.stop();
902
907
  }
903
908
  this.completeAnimation();
@@ -940,15 +945,17 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
940
945
  calcBoxDelta(this.projectionDeltaWithTransform, this.layoutCorrected, targetWithTransforms, latestValues);
941
946
  }
942
947
  registerSharedNode(layoutId, node) {
943
- var _a, _b, _c;
944
948
  if (!this.sharedNodes.has(layoutId)) {
945
949
  this.sharedNodes.set(layoutId, new NodeStack());
946
950
  }
947
951
  const stack = this.sharedNodes.get(layoutId);
948
952
  stack.add(node);
953
+ const config = node.options.initialPromotionConfig;
949
954
  node.promote({
950
- transition: (_a = node.options.initialPromotionConfig) === null || _a === void 0 ? void 0 : _a.transition,
951
- preserveFollowOpacity: (_c = (_b = node.options.initialPromotionConfig) === null || _b === void 0 ? void 0 : _b.shouldPreserveFollowOpacity) === null || _c === void 0 ? void 0 : _c.call(_b, node),
955
+ transition: config ? config.transition : undefined,
956
+ preserveFollowOpacity: config && config.shouldPreserveFollowOpacity
957
+ ? config.shouldPreserveFollowOpacity(node)
958
+ : undefined,
952
959
  });
953
960
  }
954
961
  isLead() {
@@ -1022,7 +1029,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
1022
1029
  }
1023
1030
  // Force a render of this element to apply the transform with all rotations
1024
1031
  // set to 0.
1025
- visualElement === null || visualElement === void 0 ? void 0 : visualElement.render();
1032
+ visualElement.render();
1026
1033
  // Put back all the values we reset
1027
1034
  for (const key in resetValues) {
1028
1035
  visualElement.setStaticValue(key, resetValues[key]);
@@ -1161,7 +1168,7 @@ function updateLayout(node) {
1161
1168
  node.updateLayout();
1162
1169
  }
1163
1170
  function notifyLayoutUpdate(node) {
1164
- var _a, _b, _c;
1171
+ var _a;
1165
1172
  const snapshot = ((_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) || node.snapshot;
1166
1173
  if (node.isLead() &&
1167
1174
  node.layout &&
@@ -1236,7 +1243,8 @@ function notifyLayoutUpdate(node) {
1236
1243
  });
1237
1244
  }
1238
1245
  else if (node.isLead()) {
1239
- (_c = (_b = node.options).onExitComplete) === null || _c === void 0 ? void 0 : _c.call(_b);
1246
+ const { onExitComplete } = node.options;
1247
+ onExitComplete && onExitComplete();
1240
1248
  }
1241
1249
  /**
1242
1250
  * Clearing transition
@@ -1264,7 +1272,7 @@ function clearMeasurements(node) {
1264
1272
  }
1265
1273
  function resetTransformStyle(node) {
1266
1274
  const { visualElement } = node.options;
1267
- if (visualElement === null || visualElement === void 0 ? void 0 : visualElement.getProps().onBeforeLayoutMeasure) {
1275
+ if (visualElement && visualElement.getProps().onBeforeLayoutMeasure) {
1268
1276
  visualElement.notify("BeforeLayoutMeasure");
1269
1277
  }
1270
1278
  node.resetTransform();
@@ -9,10 +9,12 @@ function nodeGroup() {
9
9
  subscriptions.set(node, node.addEventListener("willUpdate", dirtyAll));
10
10
  },
11
11
  remove: (node) => {
12
- var _a;
13
12
  nodes.delete(node);
14
- (_a = subscriptions.get(node)) === null || _a === void 0 ? void 0 : _a();
15
- subscriptions.delete(node);
13
+ const unsubscribe = subscriptions.get(node);
14
+ if (unsubscribe) {
15
+ unsubscribe();
16
+ subscriptions.delete(node);
17
+ }
16
18
  dirtyAll();
17
19
  },
18
20
  dirty: dirtyAll,
@@ -44,7 +44,6 @@ class NodeStack {
44
44
  }
45
45
  }
46
46
  promote(node, preserveFollowOpacity) {
47
- var _a;
48
47
  const prevLead = this.lead;
49
48
  if (node === prevLead)
50
49
  return;
@@ -63,7 +62,7 @@ class NodeStack {
63
62
  node.snapshot.latestValues =
64
63
  prevLead.animationValues || prevLead.latestValues;
65
64
  }
66
- if ((_a = node.root) === null || _a === void 0 ? void 0 : _a.isUpdating) {
65
+ if (node.root && node.root.isUpdating) {
67
66
  node.isLayoutDirty = true;
68
67
  }
69
68
  const { crossfade } = node.options;
@@ -86,9 +85,12 @@ class NodeStack {
86
85
  }
87
86
  exitAnimationComplete() {
88
87
  this.members.forEach((node) => {
89
- var _a, _b, _c, _d, _e;
90
- (_b = (_a = node.options).onExitComplete) === null || _b === void 0 ? void 0 : _b.call(_a);
91
- (_e = (_c = node.resumingFrom) === null || _c === void 0 ? void 0 : (_d = _c.options).onExitComplete) === null || _e === void 0 ? void 0 : _e.call(_d);
88
+ const { options, resumingFrom } = node;
89
+ options.onExitComplete && options.onExitComplete();
90
+ if (resumingFrom) {
91
+ resumingFrom.options.onExitComplete &&
92
+ resumingFrom.options.onExitComplete();
93
+ }
92
94
  });
93
95
  }
94
96
  scheduleRender() {