framer-motion 7.0.3 → 7.1.2

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 (186) hide show
  1. package/dist/cjs/index.js +2090 -2304
  2. package/dist/es/animation/animate.mjs +4 -5
  3. package/dist/es/animation/animation-controls.mjs +22 -24
  4. package/dist/es/animation/use-animated-state.mjs +23 -25
  5. package/dist/es/animation/use-animation.mjs +2 -2
  6. package/dist/es/animation/utils/default-transitions.mjs +13 -14
  7. package/dist/es/animation/utils/easing.mjs +20 -21
  8. package/dist/es/animation/utils/is-animatable.mjs +1 -1
  9. package/dist/es/animation/utils/is-keyframes-target.mjs +1 -1
  10. package/dist/es/animation/utils/transitions.mjs +30 -31
  11. package/dist/es/components/AnimatePresence/PresenceChild.mjs +18 -31
  12. package/dist/es/components/AnimatePresence/index.mjs +33 -35
  13. package/dist/es/components/AnimatePresence/use-presence.mjs +5 -5
  14. package/dist/es/components/AnimateSharedLayout.mjs +4 -5
  15. package/dist/es/components/LayoutGroup/index.mjs +12 -16
  16. package/dist/es/components/LazyMotion/index.mjs +9 -10
  17. package/dist/es/components/MotionConfig/index.mjs +5 -5
  18. package/dist/es/components/Reorder/Group.mjs +16 -16
  19. package/dist/es/components/Reorder/Item.mjs +14 -18
  20. package/dist/es/components/Reorder/index.mjs +3 -3
  21. package/dist/es/components/Reorder/utils/check-reorder.mjs +6 -6
  22. package/dist/es/context/DeprecatedLayoutGroupContext.mjs +1 -1
  23. package/dist/es/context/LayoutGroupContext.mjs +1 -1
  24. package/dist/es/context/LazyContext.mjs +1 -1
  25. package/dist/es/context/MotionConfigContext.mjs +2 -2
  26. package/dist/es/context/MotionContext/create.mjs +2 -2
  27. package/dist/es/context/MotionContext/index.mjs +1 -1
  28. package/dist/es/context/MotionContext/utils.mjs +1 -1
  29. package/dist/es/context/PresenceContext.mjs +1 -1
  30. package/dist/es/context/ReorderContext.mjs +1 -1
  31. package/dist/es/context/SwitchLayoutGroupContext.mjs +1 -1
  32. package/dist/es/events/event-info.mjs +11 -17
  33. package/dist/es/events/use-dom-event.mjs +4 -5
  34. package/dist/es/events/use-pointer-event.mjs +2 -2
  35. package/dist/es/events/utils.mjs +3 -9
  36. package/dist/es/gestures/PanSession.mjs +42 -47
  37. package/dist/es/gestures/drag/VisualElementDragControls.mjs +147 -157
  38. package/dist/es/gestures/drag/use-drag-controls.mjs +10 -12
  39. package/dist/es/gestures/drag/use-drag.mjs +4 -4
  40. package/dist/es/gestures/drag/utils/constraints.mjs +12 -17
  41. package/dist/es/gestures/drag/utils/lock.mjs +17 -17
  42. package/dist/es/gestures/use-focus-gesture.mjs +3 -4
  43. package/dist/es/gestures/use-hover-gesture.mjs +2 -3
  44. package/dist/es/gestures/use-pan-gesture.mjs +9 -10
  45. package/dist/es/gestures/use-tap-gesture.mjs +5 -6
  46. package/dist/es/gestures/utils/event-type.mjs +1 -1
  47. package/dist/es/gestures/utils/is-node-or-child.mjs +1 -1
  48. package/dist/es/index.mjs +1 -0
  49. package/dist/es/motion/features/animations.mjs +9 -11
  50. package/dist/es/motion/features/definitions.mjs +5 -5
  51. package/dist/es/motion/features/drag.mjs +1 -1
  52. package/dist/es/motion/features/gestures.mjs +1 -1
  53. package/dist/es/motion/features/layout/MeasureLayout.mjs +32 -40
  54. package/dist/es/motion/features/layout/index.mjs +1 -1
  55. package/dist/es/motion/features/use-features.mjs +8 -9
  56. package/dist/es/motion/features/use-projection.mjs +10 -11
  57. package/dist/es/motion/features/viewport/observers.mjs +12 -12
  58. package/dist/es/motion/features/viewport/use-viewport.mjs +17 -20
  59. package/dist/es/motion/index.mjs +13 -16
  60. package/dist/es/motion/utils/VisualElementHandler.mjs +10 -16
  61. package/dist/es/motion/utils/is-forced-motion-value.mjs +1 -2
  62. package/dist/es/motion/utils/make-renderless-component.mjs +2 -2
  63. package/dist/es/motion/utils/use-motion-ref.mjs +1 -1
  64. package/dist/es/motion/utils/use-visual-element.mjs +13 -13
  65. package/dist/es/motion/utils/use-visual-state.mjs +26 -31
  66. package/dist/es/motion/utils/valid-prop.mjs +1 -1
  67. package/dist/es/projection/animation/mix-values.mjs +12 -16
  68. package/dist/es/projection/geometry/conversion.mjs +4 -6
  69. package/dist/es/projection/geometry/delta-apply.mjs +14 -20
  70. package/dist/es/projection/geometry/delta-calc.mjs +2 -5
  71. package/dist/es/projection/geometry/delta-remove.mjs +6 -13
  72. package/dist/es/projection/geometry/models.mjs +7 -7
  73. package/dist/es/projection/node/DocumentProjectionNode.mjs +5 -5
  74. package/dist/es/projection/node/HTMLProjectionNode.mjs +8 -10
  75. package/dist/es/projection/node/create-projection-node.mjs +283 -307
  76. package/dist/es/projection/node/group.mjs +6 -8
  77. package/dist/es/projection/node/id.mjs +2 -2
  78. package/dist/es/projection/node/state.mjs +1 -1
  79. package/dist/es/projection/shared/stack.mjs +26 -27
  80. package/dist/es/projection/styles/scale-border-radius.mjs +5 -5
  81. package/dist/es/projection/styles/scale-box-shadow.mjs +18 -19
  82. package/dist/es/projection/styles/scale-correction.mjs +1 -1
  83. package/dist/es/projection/styles/transform.mjs +12 -12
  84. package/dist/es/projection/use-reset-projection.mjs +2 -2
  85. package/dist/es/projection/utils/has-transform.mjs +1 -2
  86. package/dist/es/projection/utils/measure.mjs +2 -2
  87. package/dist/es/render/dom/create-visual-element.mjs +1 -1
  88. package/dist/es/render/dom/features-animation.mjs +1 -2
  89. package/dist/es/render/dom/features-max.mjs +1 -2
  90. package/dist/es/render/dom/motion-minimal.mjs +1 -1
  91. package/dist/es/render/dom/motion-proxy.mjs +3 -4
  92. package/dist/es/render/dom/motion.mjs +2 -5
  93. package/dist/es/render/dom/use-render.mjs +6 -9
  94. package/dist/es/render/dom/utils/camel-to-dash.mjs +3 -5
  95. package/dist/es/render/dom/utils/create-config.mjs +5 -5
  96. package/dist/es/render/dom/utils/css-variables-conversion.mjs +19 -20
  97. package/dist/es/render/dom/utils/filter-props.mjs +4 -6
  98. package/dist/es/render/dom/utils/parse-dom-variant.mjs +2 -2
  99. package/dist/es/render/dom/utils/unit-conversion.mjs +68 -99
  100. package/dist/es/render/dom/value-types/animatable-none.mjs +1 -1
  101. package/dist/es/render/dom/value-types/defaults.mjs +4 -5
  102. package/dist/es/render/dom/value-types/dimensions.mjs +2 -4
  103. package/dist/es/render/dom/value-types/find.mjs +2 -3
  104. package/dist/es/render/dom/value-types/get-as-type.mjs +1 -1
  105. package/dist/es/render/dom/value-types/number.mjs +2 -2
  106. package/dist/es/render/dom/value-types/test.mjs +1 -1
  107. package/dist/es/render/dom/value-types/type-auto.mjs +3 -3
  108. package/dist/es/render/dom/value-types/type-int.mjs +1 -2
  109. package/dist/es/render/html/config-motion.mjs +1 -1
  110. package/dist/es/render/html/use-props.mjs +11 -13
  111. package/dist/es/render/html/utils/build-styles.mjs +8 -8
  112. package/dist/es/render/html/utils/build-transform.mjs +11 -16
  113. package/dist/es/render/html/utils/create-render-state.mjs +2 -2
  114. package/dist/es/render/html/utils/render.mjs +2 -3
  115. package/dist/es/render/html/utils/scrape-motion-values.mjs +3 -3
  116. package/dist/es/render/html/utils/transform.mjs +6 -10
  117. package/dist/es/render/html/visual-element.mjs +22 -23
  118. package/dist/es/render/index.mjs +359 -364
  119. package/dist/es/render/svg/config-motion.mjs +2 -3
  120. package/dist/es/render/svg/lowercase-elements.mjs +1 -1
  121. package/dist/es/render/svg/use-props.mjs +5 -6
  122. package/dist/es/render/svg/utils/build-attrs.mjs +2 -2
  123. package/dist/es/render/svg/utils/camel-case-attrs.mjs +1 -1
  124. package/dist/es/render/svg/utils/create-render-state.mjs +1 -2
  125. package/dist/es/render/svg/utils/path.mjs +7 -10
  126. package/dist/es/render/svg/utils/render.mjs +1 -1
  127. package/dist/es/render/svg/utils/scrape-motion-values.mjs +3 -3
  128. package/dist/es/render/svg/utils/transform-origin.mjs +3 -3
  129. package/dist/es/render/svg/visual-element.mjs +6 -4
  130. package/dist/es/render/utils/animation-state.mjs +71 -87
  131. package/dist/es/render/utils/animation.mjs +48 -60
  132. package/dist/es/render/utils/compare-by-depth.mjs +1 -3
  133. package/dist/es/render/utils/flat-tree.mjs +9 -10
  134. package/dist/es/render/utils/lifecycles.mjs +12 -19
  135. package/dist/es/render/utils/motion-values.mjs +16 -8
  136. package/dist/es/render/utils/setters.mjs +19 -19
  137. package/dist/es/render/utils/variants.mjs +6 -8
  138. package/dist/es/utils/array.mjs +9 -10
  139. package/dist/es/utils/is-browser.mjs +1 -1
  140. package/dist/es/utils/is-numerical-string.mjs +1 -1
  141. package/dist/es/utils/is-zero-value-string.mjs +1 -1
  142. package/dist/es/utils/process.mjs +2 -2
  143. package/dist/es/utils/resolve-value.mjs +2 -2
  144. package/dist/es/utils/shallow-compare.mjs +2 -2
  145. package/dist/es/utils/subscription-manager.mjs +15 -17
  146. package/dist/es/utils/time-conversion.mjs +1 -1
  147. package/dist/es/utils/transform.mjs +10 -15
  148. package/dist/es/utils/use-animation-frame.mjs +5 -6
  149. package/dist/es/utils/use-constant.mjs +1 -1
  150. package/dist/es/utils/use-cycle.mjs +9 -10
  151. package/dist/es/utils/use-force-update.mjs +4 -5
  152. package/dist/es/utils/use-in-view.mjs +7 -9
  153. package/dist/es/utils/use-instant-transition-state.mjs +1 -1
  154. package/dist/es/utils/use-instant-transition.mjs +6 -9
  155. package/dist/es/utils/use-is-mounted.mjs +3 -3
  156. package/dist/es/utils/use-isomorphic-effect.mjs +1 -1
  157. package/dist/es/utils/use-reduced-motion.mjs +8 -11
  158. package/dist/es/utils/use-unmount-effect.mjs +1 -1
  159. package/dist/es/utils/warn-once.mjs +1 -1
  160. package/dist/es/value/index.mjs +53 -59
  161. package/dist/es/value/use-combine-values.mjs +3 -3
  162. package/dist/es/value/use-inverted-scale.mjs +9 -11
  163. package/dist/es/value/use-motion-template.mjs +5 -9
  164. package/dist/es/value/use-motion-value.mjs +4 -5
  165. package/dist/es/value/use-on-change.mjs +4 -4
  166. package/dist/es/value/use-scroll.mjs +9 -11
  167. package/dist/es/value/use-spring.mjs +8 -10
  168. package/dist/es/value/use-time.mjs +2 -2
  169. package/dist/es/value/use-transform.mjs +6 -10
  170. package/dist/es/value/use-velocity.mjs +3 -3
  171. package/dist/es/value/use-will-change/index.mjs +50 -0
  172. package/dist/es/value/use-will-change/is.mjs +7 -0
  173. package/dist/es/value/utils/is-motion-value.mjs +1 -1
  174. package/dist/es/value/utils/resolve-motion-value.mjs +1 -1
  175. package/dist/framer-motion.dev.js +2134 -2414
  176. package/dist/framer-motion.js +1 -1
  177. package/dist/index.d.ts +9 -2
  178. package/dist/projection.dev.js +1154 -1300
  179. package/dist/size-rollup-dom-animation.js +1 -1
  180. package/dist/size-rollup-dom-max.js +1 -1
  181. package/dist/size-rollup-m.js +1 -1
  182. package/dist/size-webpack-dom-animation.js +1 -1
  183. package/dist/size-webpack-dom-max.js +1 -1
  184. package/dist/size-webpack-m.js +1 -1
  185. package/dist/three-entry.d.ts +0 -1
  186. package/package.json +12 -12
@@ -1,4 +1,3 @@
1
- import { __spreadArray, __read, __assign } from 'tslib';
2
1
  import sync, { cancelSync, flushSync } from 'framesync';
3
2
  import { mix } from 'popmotion';
4
3
  import { animate } from '../../animation/animate.mjs';
@@ -25,14 +24,10 @@ import { globalProjectionState } from './state.mjs';
25
24
  * We use 1000 as the animation target as 0-1000 maps better to pixels than 0-1
26
25
  * which has a noticeable difference in spring animations
27
26
  */
28
- var animationTarget = 1000;
29
- function createProjectionNode(_a) {
30
- var attachResizeListener = _a.attachResizeListener, defaultParent = _a.defaultParent, measureScroll = _a.measureScroll, checkIsScrollRoot = _a.checkIsScrollRoot, resetTransform = _a.resetTransform;
31
- return /** @class */ (function () {
32
- function ProjectionNode(id, latestValues, parent) {
33
- if (latestValues === void 0) { latestValues = {}; }
34
- if (parent === void 0) { parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent(); }
35
- var _this = this;
27
+ const animationTarget = 1000;
28
+ function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
29
+ return class ProjectionNode {
30
+ constructor(id, latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
36
31
  /**
37
32
  * A Set containing all this component's children. This is used to iterate
38
33
  * through the children.
@@ -97,15 +92,15 @@ function createProjectionNode(_a) {
97
92
  this.eventHandlers = new Map();
98
93
  // Note: Currently only running on root node
99
94
  this.potentialNodes = new Map();
100
- this.checkUpdateFailed = function () {
101
- if (_this.isUpdating) {
102
- _this.isUpdating = false;
103
- _this.clearAllSnapshots();
95
+ this.checkUpdateFailed = () => {
96
+ if (this.isUpdating) {
97
+ this.isUpdating = false;
98
+ this.clearAllSnapshots();
104
99
  }
105
100
  };
106
- this.updateProjection = function () {
107
- _this.nodes.forEach(resolveTargetDelta);
108
- _this.nodes.forEach(calcProjection);
101
+ this.updateProjection = () => {
102
+ this.nodes.forEach(resolveTargetDelta);
103
+ this.nodes.forEach(calcProjection);
109
104
  };
110
105
  this.hasProjected = false;
111
106
  this.isVisible = true;
@@ -118,49 +113,43 @@ function createProjectionNode(_a) {
118
113
  this.id = id;
119
114
  this.latestValues = latestValues;
120
115
  this.root = parent ? parent.root || parent : this;
121
- this.path = parent ? __spreadArray(__spreadArray([], __read(parent.path), false), [parent], false) : [];
116
+ this.path = parent ? [...parent.path, parent] : [];
122
117
  this.parent = parent;
123
118
  this.depth = parent ? parent.depth + 1 : 0;
124
119
  id && this.root.registerPotentialNode(id, this);
125
- for (var i = 0; i < this.path.length; i++) {
120
+ for (let i = 0; i < this.path.length; i++) {
126
121
  this.path[i].shouldResetTransform = true;
127
122
  }
128
123
  if (this.root === this)
129
124
  this.nodes = new FlatTree();
130
125
  }
131
- ProjectionNode.prototype.addEventListener = function (name, handler) {
126
+ addEventListener(name, handler) {
132
127
  if (!this.eventHandlers.has(name)) {
133
128
  this.eventHandlers.set(name, new SubscriptionManager());
134
129
  }
135
130
  return this.eventHandlers.get(name).add(handler);
136
- };
137
- ProjectionNode.prototype.notifyListeners = function (name) {
138
- var args = [];
139
- for (var _i = 1; _i < arguments.length; _i++) {
140
- args[_i - 1] = arguments[_i];
141
- }
142
- var subscriptionManager = this.eventHandlers.get(name);
143
- subscriptionManager === null || subscriptionManager === void 0 ? void 0 : subscriptionManager.notify.apply(subscriptionManager, __spreadArray([], __read(args), false));
144
- };
145
- ProjectionNode.prototype.hasListeners = function (name) {
131
+ }
132
+ notifyListeners(name, ...args) {
133
+ const subscriptionManager = this.eventHandlers.get(name);
134
+ subscriptionManager === null || subscriptionManager === void 0 ? void 0 : subscriptionManager.notify(...args);
135
+ }
136
+ hasListeners(name) {
146
137
  return this.eventHandlers.has(name);
147
- };
148
- ProjectionNode.prototype.registerPotentialNode = function (id, node) {
138
+ }
139
+ registerPotentialNode(id, node) {
149
140
  this.potentialNodes.set(id, node);
150
- };
141
+ }
151
142
  /**
152
143
  * Lifecycles
153
144
  */
154
- ProjectionNode.prototype.mount = function (instance, isLayoutDirty) {
155
- var _this = this;
145
+ mount(instance, isLayoutDirty = false) {
156
146
  var _a;
157
- if (isLayoutDirty === void 0) { isLayoutDirty = false; }
158
147
  if (this.instance)
159
148
  return;
160
149
  this.isSVG =
161
150
  instance instanceof SVGElement && instance.tagName !== "svg";
162
151
  this.instance = instance;
163
- var _b = this.options, layoutId = _b.layoutId, layout = _b.layout, visualElement = _b.visualElement;
152
+ const { layoutId, layout, visualElement } = this.options;
164
153
  if (visualElement && !visualElement.getInstance()) {
165
154
  visualElement.mount(instance);
166
155
  }
@@ -171,17 +160,15 @@ function createProjectionNode(_a) {
171
160
  this.isLayoutDirty = true;
172
161
  }
173
162
  if (attachResizeListener) {
174
- var unblockTimeout_1;
175
- var resizeUnblockUpdate_1 = function () {
176
- return (_this.root.updateBlockedByResize = false);
177
- };
178
- attachResizeListener(instance, function () {
179
- _this.root.updateBlockedByResize = true;
180
- clearTimeout(unblockTimeout_1);
181
- unblockTimeout_1 = window.setTimeout(resizeUnblockUpdate_1, 250);
163
+ let unblockTimeout;
164
+ const resizeUnblockUpdate = () => (this.root.updateBlockedByResize = false);
165
+ attachResizeListener(instance, () => {
166
+ this.root.updateBlockedByResize = true;
167
+ clearTimeout(unblockTimeout);
168
+ unblockTimeout = window.setTimeout(resizeUnblockUpdate, 250);
182
169
  if (globalProjectionState.hasAnimatedSinceResize) {
183
170
  globalProjectionState.hasAnimatedSinceResize = false;
184
- _this.nodes.forEach(finishAnimation);
171
+ this.nodes.forEach(finishAnimation);
185
172
  }
186
173
  });
187
174
  }
@@ -192,45 +179,44 @@ function createProjectionNode(_a) {
192
179
  if (this.options.animate !== false &&
193
180
  visualElement &&
194
181
  (layoutId || layout)) {
195
- this.addEventListener("didUpdate", function (_a) {
196
- var _b, _c, _d, _e, _f;
197
- var delta = _a.delta, hasLayoutChanged = _a.hasLayoutChanged, hasRelativeTargetChanged = _a.hasRelativeTargetChanged, newLayout = _a.layout;
198
- if (_this.isTreeAnimationBlocked()) {
199
- _this.target = undefined;
200
- _this.relativeTarget = undefined;
182
+ this.addEventListener("didUpdate", ({ delta, hasLayoutChanged, hasRelativeTargetChanged, layout: newLayout, }) => {
183
+ var _a, _b, _c, _d, _e;
184
+ if (this.isTreeAnimationBlocked()) {
185
+ this.target = undefined;
186
+ this.relativeTarget = undefined;
201
187
  return;
202
188
  }
203
189
  // TODO: Check here if an animation exists
204
- var layoutTransition = (_c = (_b = _this.options.transition) !== null && _b !== void 0 ? _b : visualElement.getDefaultTransition()) !== null && _c !== void 0 ? _c : defaultLayoutTransition;
205
- var _g = visualElement.getProps(), onLayoutAnimationStart = _g.onLayoutAnimationStart, onLayoutAnimationComplete = _g.onLayoutAnimationComplete;
190
+ const layoutTransition = (_b = (_a = this.options.transition) !== null && _a !== void 0 ? _a : visualElement.getDefaultTransition()) !== null && _b !== void 0 ? _b : defaultLayoutTransition;
191
+ const { onLayoutAnimationStart, onLayoutAnimationComplete, } = visualElement.getProps();
206
192
  /**
207
193
  * The target layout of the element might stay the same,
208
194
  * but its position relative to its parent has changed.
209
195
  */
210
- var targetChanged = !_this.targetLayout ||
211
- !boxEquals(_this.targetLayout, newLayout) ||
196
+ const targetChanged = !this.targetLayout ||
197
+ !boxEquals(this.targetLayout, newLayout) ||
212
198
  hasRelativeTargetChanged;
213
199
  /**
214
200
  * If the layout hasn't seemed to have changed, it might be that the
215
201
  * element is visually in the same place in the document but its position
216
202
  * relative to its parent has indeed changed. So here we check for that.
217
203
  */
218
- var hasOnlyRelativeTargetChanged = !hasLayoutChanged && hasRelativeTargetChanged;
219
- if (((_d = _this.resumeFrom) === null || _d === void 0 ? void 0 : _d.instance) ||
204
+ const hasOnlyRelativeTargetChanged = !hasLayoutChanged && hasRelativeTargetChanged;
205
+ if (((_c = this.resumeFrom) === null || _c === void 0 ? void 0 : _c.instance) ||
220
206
  hasOnlyRelativeTargetChanged ||
221
207
  (hasLayoutChanged &&
222
- (targetChanged || !_this.currentAnimation))) {
223
- if (_this.resumeFrom) {
224
- _this.resumingFrom = _this.resumeFrom;
225
- _this.resumingFrom.resumingFrom = undefined;
208
+ (targetChanged || !this.currentAnimation))) {
209
+ if (this.resumeFrom) {
210
+ this.resumingFrom = this.resumeFrom;
211
+ this.resumingFrom.resumingFrom = undefined;
226
212
  }
227
- _this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged);
228
- var animationOptions = __assign(__assign({}, getValueTransition(layoutTransition, "layout")), { onPlay: onLayoutAnimationStart, onComplete: onLayoutAnimationComplete });
213
+ this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged);
214
+ const animationOptions = Object.assign(Object.assign({}, getValueTransition(layoutTransition, "layout")), { onPlay: onLayoutAnimationStart, onComplete: onLayoutAnimationComplete });
229
215
  if (visualElement.shouldReduceMotion) {
230
216
  animationOptions.delay = 0;
231
217
  animationOptions.type = false;
232
218
  }
233
- _this.startAnimation(animationOptions);
219
+ this.startAnimation(animationOptions);
234
220
  }
235
221
  else {
236
222
  /**
@@ -239,16 +225,16 @@ function createProjectionNode(_a) {
239
225
  * that was probably never commited to screen and look like a jumpy box.
240
226
  */
241
227
  if (!hasLayoutChanged &&
242
- _this.animationProgress === 0) {
243
- _this.finishAnimation();
228
+ this.animationProgress === 0) {
229
+ this.finishAnimation();
244
230
  }
245
- _this.isLead() && ((_f = (_e = _this.options).onExitComplete) === null || _f === void 0 ? void 0 : _f.call(_e));
231
+ this.isLead() && ((_e = (_d = this.options).onExitComplete) === null || _e === void 0 ? void 0 : _e.call(_d));
246
232
  }
247
- _this.targetLayout = newLayout;
233
+ this.targetLayout = newLayout;
248
234
  });
249
235
  }
250
- };
251
- ProjectionNode.prototype.unmount = function () {
236
+ }
237
+ unmount() {
252
238
  var _a, _b;
253
239
  this.options.layoutId && this.willUpdate();
254
240
  this.root.nodes.remove(this);
@@ -256,34 +242,33 @@ function createProjectionNode(_a) {
256
242
  (_b = this.parent) === null || _b === void 0 ? void 0 : _b.children.delete(this);
257
243
  this.instance = undefined;
258
244
  cancelSync.preRender(this.updateProjection);
259
- };
245
+ }
260
246
  // only on the root
261
- ProjectionNode.prototype.blockUpdate = function () {
247
+ blockUpdate() {
262
248
  this.updateManuallyBlocked = true;
263
- };
264
- ProjectionNode.prototype.unblockUpdate = function () {
249
+ }
250
+ unblockUpdate() {
265
251
  this.updateManuallyBlocked = false;
266
- };
267
- ProjectionNode.prototype.isUpdateBlocked = function () {
252
+ }
253
+ isUpdateBlocked() {
268
254
  return this.updateManuallyBlocked || this.updateBlockedByResize;
269
- };
270
- ProjectionNode.prototype.isTreeAnimationBlocked = function () {
255
+ }
256
+ isTreeAnimationBlocked() {
271
257
  var _a;
272
258
  return (this.isAnimationBlocked ||
273
259
  ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isTreeAnimationBlocked()) ||
274
260
  false);
275
- };
261
+ }
276
262
  // Note: currently only running on root node
277
- ProjectionNode.prototype.startUpdate = function () {
263
+ startUpdate() {
278
264
  var _a;
279
265
  if (this.isUpdateBlocked())
280
266
  return;
281
267
  this.isUpdating = true;
282
268
  (_a = this.nodes) === null || _a === void 0 ? void 0 : _a.forEach(resetRotation);
283
- };
284
- ProjectionNode.prototype.willUpdate = function (shouldNotifyListeners) {
269
+ }
270
+ willUpdate(shouldNotifyListeners = true) {
285
271
  var _a, _b, _c;
286
- if (shouldNotifyListeners === void 0) { shouldNotifyListeners = true; }
287
272
  if (this.root.isUpdateBlocked()) {
288
273
  (_b = (_a = this.options).onExitComplete) === null || _b === void 0 ? void 0 : _b.call(_a);
289
274
  return;
@@ -292,8 +277,8 @@ function createProjectionNode(_a) {
292
277
  if (this.isLayoutDirty)
293
278
  return;
294
279
  this.isLayoutDirty = true;
295
- for (var i = 0; i < this.path.length; i++) {
296
- var node = this.path[i];
280
+ for (let i = 0; i < this.path.length; i++) {
281
+ const node = this.path[i];
297
282
  node.shouldResetTransform = true;
298
283
  /**
299
284
  * TODO: Check we haven't updated the scroll
@@ -301,17 +286,17 @@ function createProjectionNode(_a) {
301
286
  */
302
287
  node.updateScroll();
303
288
  }
304
- var _d = this.options, layoutId = _d.layoutId, layout = _d.layout;
289
+ const { layoutId, layout } = this.options;
305
290
  if (layoutId === undefined && !layout)
306
291
  return;
307
- var transformTemplate = (_c = this.options.visualElement) === null || _c === void 0 ? void 0 : _c.getProps().transformTemplate;
292
+ const transformTemplate = (_c = this.options.visualElement) === null || _c === void 0 ? void 0 : _c.getProps().transformTemplate;
308
293
  this.prevTransformTemplateValue = transformTemplate === null || transformTemplate === void 0 ? void 0 : transformTemplate(this.latestValues, "");
309
294
  this.updateSnapshot();
310
295
  shouldNotifyListeners && this.notifyListeners("willUpdate");
311
- };
296
+ }
312
297
  // Note: Currently only running on root node
313
- ProjectionNode.prototype.didUpdate = function () {
314
- var updateWasBlocked = this.isUpdateBlocked();
298
+ didUpdate() {
299
+ const updateWasBlocked = this.isUpdateBlocked();
315
300
  // When doing an instant transition, we skip the layout update,
316
301
  // but should still clean up the measurements so that the next
317
302
  // snapshot could be taken correctly.
@@ -353,46 +338,45 @@ function createProjectionNode(_a) {
353
338
  flushSync.update();
354
339
  flushSync.preRender();
355
340
  flushSync.render();
356
- };
357
- ProjectionNode.prototype.clearAllSnapshots = function () {
341
+ }
342
+ clearAllSnapshots() {
358
343
  this.nodes.forEach(clearSnapshot);
359
344
  this.sharedNodes.forEach(removeLeadSnapshots);
360
- };
361
- ProjectionNode.prototype.scheduleUpdateProjection = function () {
345
+ }
346
+ scheduleUpdateProjection() {
362
347
  sync.preRender(this.updateProjection, false, true);
363
- };
364
- ProjectionNode.prototype.scheduleCheckAfterUnmount = function () {
365
- var _this = this;
348
+ }
349
+ scheduleCheckAfterUnmount() {
366
350
  /**
367
351
  * If the unmounting node is in a layoutGroup and did trigger a willUpdate,
368
352
  * we manually call didUpdate to give a chance to the siblings to animate.
369
353
  * Otherwise, cleanup all snapshots to prevents future nodes from reusing them.
370
354
  */
371
- sync.postRender(function () {
372
- if (_this.isLayoutDirty) {
373
- _this.root.didUpdate();
355
+ sync.postRender(() => {
356
+ if (this.isLayoutDirty) {
357
+ this.root.didUpdate();
374
358
  }
375
359
  else {
376
- _this.root.checkUpdateFailed();
360
+ this.root.checkUpdateFailed();
377
361
  }
378
362
  });
379
- };
363
+ }
380
364
  /**
381
365
  * Update measurements
382
366
  */
383
- ProjectionNode.prototype.updateSnapshot = function () {
367
+ updateSnapshot() {
384
368
  if (this.snapshot || !this.instance)
385
369
  return;
386
- var measured = this.measure();
387
- var layout = this.removeTransform(this.removeElementScroll(measured));
370
+ const measured = this.measure();
371
+ const layout = this.removeTransform(this.removeElementScroll(measured));
388
372
  roundBox(layout);
389
373
  this.snapshot = {
390
- measured: measured,
391
- layout: layout,
374
+ measured,
375
+ layout,
392
376
  latestValues: {},
393
377
  };
394
- };
395
- ProjectionNode.prototype.updateLayout = function () {
378
+ }
379
+ updateLayout() {
396
380
  var _a;
397
381
  if (!this.instance)
398
382
  return;
@@ -410,16 +394,16 @@ function createProjectionNode(_a) {
410
394
  * up to date.
411
395
  */
412
396
  if (this.resumeFrom && !this.resumeFrom.instance) {
413
- for (var i = 0; i < this.path.length; i++) {
414
- var node = this.path[i];
397
+ for (let i = 0; i < this.path.length; i++) {
398
+ const node = this.path[i];
415
399
  node.updateScroll();
416
400
  }
417
401
  }
418
- var measured = this.measure();
402
+ const measured = this.measure();
419
403
  roundBox(measured);
420
- var prevLayout = this.layout;
404
+ const prevLayout = this.layout;
421
405
  this.layout = {
422
- measured: measured,
406
+ measured,
423
407
  actual: this.removeElementScroll(measured),
424
408
  };
425
409
  this.layoutCorrected = createBox();
@@ -427,22 +411,22 @@ function createProjectionNode(_a) {
427
411
  this.projectionDelta = undefined;
428
412
  this.notifyListeners("measure", this.layout.actual);
429
413
  (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.notifyLayoutMeasure(this.layout.actual, prevLayout === null || prevLayout === void 0 ? void 0 : prevLayout.actual);
430
- };
431
- ProjectionNode.prototype.updateScroll = function () {
414
+ }
415
+ updateScroll() {
432
416
  if (this.options.layoutScroll && this.instance) {
433
417
  this.isScrollRoot = checkIsScrollRoot(this.instance);
434
418
  this.scroll = measureScroll(this.instance);
435
419
  }
436
- };
437
- ProjectionNode.prototype.resetTransform = function () {
420
+ }
421
+ resetTransform() {
438
422
  var _a;
439
423
  if (!resetTransform)
440
424
  return;
441
- var isResetRequested = this.isLayoutDirty || this.shouldResetTransform;
442
- var hasProjection = this.projectionDelta && !isDeltaZero(this.projectionDelta);
443
- var transformTemplate = (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.getProps().transformTemplate;
444
- var transformTemplateValue = transformTemplate === null || transformTemplate === void 0 ? void 0 : transformTemplate(this.latestValues, "");
445
- var transformTemplateHasChanged = transformTemplateValue !== this.prevTransformTemplateValue;
425
+ const isResetRequested = this.isLayoutDirty || this.shouldResetTransform;
426
+ const hasProjection = this.projectionDelta && !isDeltaZero(this.projectionDelta);
427
+ const transformTemplate = (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.getProps().transformTemplate;
428
+ const transformTemplateValue = transformTemplate === null || transformTemplate === void 0 ? void 0 : transformTemplate(this.latestValues, "");
429
+ const transformTemplateHasChanged = transformTemplateValue !== this.prevTransformTemplateValue;
446
430
  if (isResetRequested &&
447
431
  (hasProjection ||
448
432
  hasTransform(this.latestValues) ||
@@ -451,38 +435,38 @@ function createProjectionNode(_a) {
451
435
  this.shouldResetTransform = false;
452
436
  this.scheduleRender();
453
437
  }
454
- };
455
- ProjectionNode.prototype.measure = function () {
456
- var visualElement = this.options.visualElement;
438
+ }
439
+ measure() {
440
+ const { visualElement } = this.options;
457
441
  if (!visualElement)
458
442
  return createBox();
459
- var box = visualElement.measureViewportBox();
443
+ const box = visualElement.measureViewportBox();
460
444
  // Remove viewport scroll to give page-relative coordinates
461
- var scroll = this.root.scroll;
445
+ const { scroll } = this.root;
462
446
  if (scroll) {
463
447
  translateAxis(box.x, scroll.x);
464
448
  translateAxis(box.y, scroll.y);
465
449
  }
466
450
  return box;
467
- };
468
- ProjectionNode.prototype.removeElementScroll = function (box) {
469
- var boxWithoutScroll = createBox();
451
+ }
452
+ removeElementScroll(box) {
453
+ const boxWithoutScroll = createBox();
470
454
  copyBoxInto(boxWithoutScroll, box);
471
455
  /**
472
456
  * Performance TODO: Keep a cumulative scroll offset down the tree
473
457
  * rather than loop back up the path.
474
458
  */
475
- for (var i = 0; i < this.path.length; i++) {
476
- var node = this.path[i];
477
- var scroll_1 = node.scroll, options = node.options, isScrollRoot = node.isScrollRoot;
478
- if (node !== this.root && scroll_1 && options.layoutScroll) {
459
+ for (let i = 0; i < this.path.length; i++) {
460
+ const node = this.path[i];
461
+ const { scroll, options, isScrollRoot } = node;
462
+ if (node !== this.root && scroll && options.layoutScroll) {
479
463
  /**
480
464
  * If this is a new scroll root, we want to remove all previous scrolls
481
465
  * from the viewport box.
482
466
  */
483
467
  if (isScrollRoot) {
484
468
  copyBoxInto(boxWithoutScroll, box);
485
- var rootScroll = this.root.scroll;
469
+ const { scroll: rootScroll } = this.root;
486
470
  /**
487
471
  * Undo the application of page scroll that was originally added
488
472
  * to the measured bounding box.
@@ -492,18 +476,17 @@ function createProjectionNode(_a) {
492
476
  translateAxis(boxWithoutScroll.y, -rootScroll.y);
493
477
  }
494
478
  }
495
- translateAxis(boxWithoutScroll.x, scroll_1.x);
496
- translateAxis(boxWithoutScroll.y, scroll_1.y);
479
+ translateAxis(boxWithoutScroll.x, scroll.x);
480
+ translateAxis(boxWithoutScroll.y, scroll.y);
497
481
  }
498
482
  }
499
483
  return boxWithoutScroll;
500
- };
501
- ProjectionNode.prototype.applyTransform = function (box, transformOnly) {
502
- if (transformOnly === void 0) { transformOnly = false; }
503
- var withTransforms = createBox();
484
+ }
485
+ applyTransform(box, transformOnly = false) {
486
+ const withTransforms = createBox();
504
487
  copyBoxInto(withTransforms, box);
505
- for (var i = 0; i < this.path.length; i++) {
506
- var node = this.path[i];
488
+ for (let i = 0; i < this.path.length; i++) {
489
+ const node = this.path[i];
507
490
  if (!transformOnly &&
508
491
  node.options.layoutScroll &&
509
492
  node.scroll &&
@@ -521,20 +504,20 @@ function createProjectionNode(_a) {
521
504
  transformBox(withTransforms, this.latestValues);
522
505
  }
523
506
  return withTransforms;
524
- };
525
- ProjectionNode.prototype.removeTransform = function (box) {
507
+ }
508
+ removeTransform(box) {
526
509
  var _a;
527
- var boxWithoutTransform = createBox();
510
+ const boxWithoutTransform = createBox();
528
511
  copyBoxInto(boxWithoutTransform, box);
529
- for (var i = 0; i < this.path.length; i++) {
530
- var node = this.path[i];
512
+ for (let i = 0; i < this.path.length; i++) {
513
+ const node = this.path[i];
531
514
  if (!node.instance)
532
515
  continue;
533
516
  if (!hasTransform(node.latestValues))
534
517
  continue;
535
518
  hasScale(node.latestValues) && node.updateSnapshot();
536
- var sourceBox = createBox();
537
- var nodeBox = node.measure();
519
+ const sourceBox = createBox();
520
+ const nodeBox = node.measure();
538
521
  copyBoxInto(sourceBox, nodeBox);
539
522
  removeBoxTransforms(boxWithoutTransform, node.latestValues, (_a = node.snapshot) === null || _a === void 0 ? void 0 : _a.layout, sourceBox);
540
523
  }
@@ -542,19 +525,19 @@ function createProjectionNode(_a) {
542
525
  removeBoxTransforms(boxWithoutTransform, this.latestValues);
543
526
  }
544
527
  return boxWithoutTransform;
545
- };
528
+ }
546
529
  /**
547
530
  *
548
531
  */
549
- ProjectionNode.prototype.setTargetDelta = function (delta) {
532
+ setTargetDelta(delta) {
550
533
  this.targetDelta = delta;
551
534
  this.root.scheduleUpdateProjection();
552
- };
553
- ProjectionNode.prototype.setOptions = function (options) {
535
+ }
536
+ setOptions(options) {
554
537
  var _a;
555
- this.options = __assign(__assign(__assign({}, this.options), options), { crossfade: (_a = options.crossfade) !== null && _a !== void 0 ? _a : true });
556
- };
557
- ProjectionNode.prototype.clearMeasurements = function () {
538
+ this.options = Object.assign(Object.assign(Object.assign({}, this.options), options), { crossfade: (_a = options.crossfade) !== null && _a !== void 0 ? _a : true });
539
+ }
540
+ clearMeasurements() {
558
541
  this.scroll = undefined;
559
542
  this.layout = undefined;
560
543
  this.snapshot = undefined;
@@ -562,13 +545,13 @@ function createProjectionNode(_a) {
562
545
  this.targetDelta = undefined;
563
546
  this.target = undefined;
564
547
  this.isLayoutDirty = false;
565
- };
548
+ }
566
549
  /**
567
550
  * Frame calculations
568
551
  */
569
- ProjectionNode.prototype.resolveTargetDelta = function () {
552
+ resolveTargetDelta() {
570
553
  var _a;
571
- var _b = this.options, layout = _b.layout, layoutId = _b.layoutId;
554
+ const { layout, layoutId } = this.options;
572
555
  /**
573
556
  * If we have no layout, we can't perform projection, so early return
574
557
  */
@@ -647,8 +630,8 @@ function createProjectionNode(_a) {
647
630
  copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
648
631
  }
649
632
  }
650
- };
651
- ProjectionNode.prototype.getClosestProjectingParent = function () {
633
+ }
634
+ getClosestProjectingParent() {
652
635
  if (!this.parent || hasTransform(this.parent.latestValues))
653
636
  return undefined;
654
637
  if ((this.parent.relativeTarget || this.parent.targetDelta) &&
@@ -658,10 +641,10 @@ function createProjectionNode(_a) {
658
641
  else {
659
642
  return this.parent.getClosestProjectingParent();
660
643
  }
661
- };
662
- ProjectionNode.prototype.calcProjection = function () {
644
+ }
645
+ calcProjection() {
663
646
  var _a;
664
- var _b = this.options, layout = _b.layout, layoutId = _b.layoutId;
647
+ const { layout, layoutId } = this.options;
665
648
  /**
666
649
  * If this section of the tree isn't animating we can
667
650
  * delete our target sources for the following frame.
@@ -674,7 +657,7 @@ function createProjectionNode(_a) {
674
657
  }
675
658
  if (!this.layout || !(layout || layoutId))
676
659
  return;
677
- var lead = this.getLead();
660
+ const lead = this.getLead();
678
661
  /**
679
662
  * Reset the corrected box with the latest values from box, as we're then going
680
663
  * to perform mutative operations on it.
@@ -685,16 +668,16 @@ function createProjectionNode(_a) {
685
668
  * is the layout box, as it will appear on screen as a result of the transforms of its parents.
686
669
  */
687
670
  applyTreeDeltas(this.layoutCorrected, this.treeScale, this.path, Boolean(this.resumingFrom) || this !== lead);
688
- var target = lead.target;
671
+ const { target } = lead;
689
672
  if (!target)
690
673
  return;
691
674
  if (!this.projectionDelta) {
692
675
  this.projectionDelta = createDelta();
693
676
  this.projectionDeltaWithTransform = createDelta();
694
677
  }
695
- var prevTreeScaleX = this.treeScale.x;
696
- var prevTreeScaleY = this.treeScale.y;
697
- var prevProjectionTransform = this.projectionTransform;
678
+ const prevTreeScaleX = this.treeScale.x;
679
+ const prevTreeScaleY = this.treeScale.y;
680
+ const prevProjectionTransform = this.projectionTransform;
698
681
  /**
699
682
  * Update the delta between the corrected box and the target box before user-set transforms were applied.
700
683
  * This will allow us to calculate the corrected borderRadius and boxShadow to compensate
@@ -713,67 +696,63 @@ function createProjectionNode(_a) {
713
696
  this.scheduleRender();
714
697
  this.notifyListeners("projectionUpdate", target);
715
698
  }
716
- };
717
- ProjectionNode.prototype.hide = function () {
699
+ }
700
+ hide() {
718
701
  this.isVisible = false;
719
702
  // TODO: Schedule render
720
- };
721
- ProjectionNode.prototype.show = function () {
703
+ }
704
+ show() {
722
705
  this.isVisible = true;
723
706
  // TODO: Schedule render
724
- };
725
- ProjectionNode.prototype.scheduleRender = function (notifyAll) {
707
+ }
708
+ scheduleRender(notifyAll = true) {
726
709
  var _a, _b, _c;
727
- if (notifyAll === void 0) { notifyAll = true; }
728
710
  (_b = (_a = this.options).scheduleRender) === null || _b === void 0 ? void 0 : _b.call(_a);
729
711
  notifyAll && ((_c = this.getStack()) === null || _c === void 0 ? void 0 : _c.scheduleRender());
730
712
  if (this.resumingFrom && !this.resumingFrom.instance) {
731
713
  this.resumingFrom = undefined;
732
714
  }
733
- };
734
- ProjectionNode.prototype.setAnimationOrigin = function (delta, hasOnlyRelativeTargetChanged) {
735
- var _this = this;
715
+ }
716
+ setAnimationOrigin(delta, hasOnlyRelativeTargetChanged = false) {
736
717
  var _a;
737
- if (hasOnlyRelativeTargetChanged === void 0) { hasOnlyRelativeTargetChanged = false; }
738
- var snapshot = this.snapshot;
739
- var snapshotLatestValues = (snapshot === null || snapshot === void 0 ? void 0 : snapshot.latestValues) || {};
740
- var mixedValues = __assign({}, this.latestValues);
741
- var targetDelta = createDelta();
718
+ const snapshot = this.snapshot;
719
+ const snapshotLatestValues = (snapshot === null || snapshot === void 0 ? void 0 : snapshot.latestValues) || {};
720
+ const mixedValues = Object.assign({}, this.latestValues);
721
+ const targetDelta = createDelta();
742
722
  this.relativeTarget = this.relativeTargetOrigin = undefined;
743
723
  this.attemptToResolveRelativeTarget = !hasOnlyRelativeTargetChanged;
744
- var relativeLayout = createBox();
745
- var isSharedLayoutAnimation = snapshot === null || snapshot === void 0 ? void 0 : snapshot.isShared;
746
- var isOnlyMember = (((_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.members.length) || 0) <= 1;
747
- var shouldCrossfadeOpacity = Boolean(isSharedLayoutAnimation &&
724
+ const relativeLayout = createBox();
725
+ const isSharedLayoutAnimation = snapshot === null || snapshot === void 0 ? void 0 : snapshot.isShared;
726
+ const isOnlyMember = (((_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.members.length) || 0) <= 1;
727
+ const shouldCrossfadeOpacity = Boolean(isSharedLayoutAnimation &&
748
728
  !isOnlyMember &&
749
729
  this.options.crossfade === true &&
750
730
  !this.path.some(hasOpacityCrossfade));
751
731
  this.animationProgress = 0;
752
- this.mixTargetDelta = function (latest) {
732
+ this.mixTargetDelta = (latest) => {
753
733
  var _a;
754
- var progress = latest / 1000;
734
+ const progress = latest / 1000;
755
735
  mixAxisDelta(targetDelta.x, delta.x, progress);
756
736
  mixAxisDelta(targetDelta.y, delta.y, progress);
757
- _this.setTargetDelta(targetDelta);
758
- if (_this.relativeTarget &&
759
- _this.relativeTargetOrigin &&
760
- _this.layout &&
761
- ((_a = _this.relativeParent) === null || _a === void 0 ? void 0 : _a.layout)) {
762
- calcRelativePosition(relativeLayout, _this.layout.actual, _this.relativeParent.layout.actual);
763
- mixBox(_this.relativeTarget, _this.relativeTargetOrigin, relativeLayout, progress);
737
+ this.setTargetDelta(targetDelta);
738
+ if (this.relativeTarget &&
739
+ this.relativeTargetOrigin &&
740
+ this.layout &&
741
+ ((_a = this.relativeParent) === null || _a === void 0 ? void 0 : _a.layout)) {
742
+ calcRelativePosition(relativeLayout, this.layout.actual, this.relativeParent.layout.actual);
743
+ mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
764
744
  }
765
745
  if (isSharedLayoutAnimation) {
766
- _this.animationValues = mixedValues;
767
- mixValues(mixedValues, snapshotLatestValues, _this.latestValues, progress, shouldCrossfadeOpacity, isOnlyMember);
746
+ this.animationValues = mixedValues;
747
+ mixValues(mixedValues, snapshotLatestValues, this.latestValues, progress, shouldCrossfadeOpacity, isOnlyMember);
768
748
  }
769
- _this.root.scheduleUpdateProjection();
770
- _this.scheduleRender();
771
- _this.animationProgress = progress;
749
+ this.root.scheduleUpdateProjection();
750
+ this.scheduleRender();
751
+ this.animationProgress = progress;
772
752
  };
773
753
  this.mixTargetDelta(0);
774
- };
775
- ProjectionNode.prototype.startAnimation = function (options) {
776
- var _this = this;
754
+ }
755
+ startAnimation(options) {
777
756
  var _a, _b;
778
757
  this.notifyListeners("animationStart");
779
758
  (_a = this.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop();
@@ -789,24 +768,24 @@ function createProjectionNode(_a) {
789
768
  * where the target is the same as when the animation started, so we can
790
769
  * calculate the relative positions correctly for instant transitions.
791
770
  */
792
- this.pendingAnimation = sync.update(function () {
771
+ this.pendingAnimation = sync.update(() => {
793
772
  globalProjectionState.hasAnimatedSinceResize = true;
794
- _this.currentAnimation = animate(0, animationTarget, __assign(__assign({}, options), { onUpdate: function (latest) {
773
+ this.currentAnimation = animate(0, animationTarget, Object.assign(Object.assign({}, options), { onUpdate: (latest) => {
795
774
  var _a;
796
- _this.mixTargetDelta(latest);
775
+ this.mixTargetDelta(latest);
797
776
  (_a = options.onUpdate) === null || _a === void 0 ? void 0 : _a.call(options, latest);
798
- }, onComplete: function () {
777
+ }, onComplete: () => {
799
778
  var _a;
800
779
  (_a = options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options);
801
- _this.completeAnimation();
780
+ this.completeAnimation();
802
781
  } }));
803
- if (_this.resumingFrom) {
804
- _this.resumingFrom.currentAnimation = _this.currentAnimation;
782
+ if (this.resumingFrom) {
783
+ this.resumingFrom.currentAnimation = this.currentAnimation;
805
784
  }
806
- _this.pendingAnimation = undefined;
785
+ this.pendingAnimation = undefined;
807
786
  });
808
- };
809
- ProjectionNode.prototype.completeAnimation = function () {
787
+ }
788
+ completeAnimation() {
810
789
  var _a;
811
790
  if (this.resumingFrom) {
812
791
  this.resumingFrom.currentAnimation = undefined;
@@ -818,17 +797,17 @@ function createProjectionNode(_a) {
818
797
  this.animationValues =
819
798
  undefined;
820
799
  this.notifyListeners("animationComplete");
821
- };
822
- ProjectionNode.prototype.finishAnimation = function () {
800
+ }
801
+ finishAnimation() {
823
802
  var _a;
824
803
  if (this.currentAnimation) {
825
804
  (_a = this.mixTargetDelta) === null || _a === void 0 ? void 0 : _a.call(this, animationTarget);
826
805
  this.currentAnimation.stop();
827
806
  }
828
807
  this.completeAnimation();
829
- };
830
- ProjectionNode.prototype.applyTransformsToTarget = function () {
831
- var _a = this.getLead(), targetWithTransforms = _a.targetWithTransforms, target = _a.target, layout = _a.layout, latestValues = _a.latestValues;
808
+ }
809
+ applyTransformsToTarget() {
810
+ const { targetWithTransforms, target, layout, latestValues } = this.getLead();
832
811
  if (!targetWithTransforms || !target || !layout)
833
812
  return;
834
813
  copyBoxInto(targetWithTransforms, target);
@@ -845,41 +824,40 @@ function createProjectionNode(_a) {
845
824
  * into the desired bounding box.
846
825
  */
847
826
  calcBoxDelta(this.projectionDeltaWithTransform, this.layoutCorrected, targetWithTransforms, latestValues);
848
- };
849
- ProjectionNode.prototype.registerSharedNode = function (layoutId, node) {
827
+ }
828
+ registerSharedNode(layoutId, node) {
850
829
  var _a, _b, _c;
851
830
  if (!this.sharedNodes.has(layoutId)) {
852
831
  this.sharedNodes.set(layoutId, new NodeStack());
853
832
  }
854
- var stack = this.sharedNodes.get(layoutId);
833
+ const stack = this.sharedNodes.get(layoutId);
855
834
  stack.add(node);
856
835
  node.promote({
857
836
  transition: (_a = node.options.initialPromotionConfig) === null || _a === void 0 ? void 0 : _a.transition,
858
837
  preserveFollowOpacity: (_c = (_b = node.options.initialPromotionConfig) === null || _b === void 0 ? void 0 : _b.shouldPreserveFollowOpacity) === null || _c === void 0 ? void 0 : _c.call(_b, node),
859
838
  });
860
- };
861
- ProjectionNode.prototype.isLead = function () {
862
- var stack = this.getStack();
839
+ }
840
+ isLead() {
841
+ const stack = this.getStack();
863
842
  return stack ? stack.lead === this : true;
864
- };
865
- ProjectionNode.prototype.getLead = function () {
843
+ }
844
+ getLead() {
866
845
  var _a;
867
- var layoutId = this.options.layoutId;
846
+ const { layoutId } = this.options;
868
847
  return layoutId ? ((_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.lead) || this : this;
869
- };
870
- ProjectionNode.prototype.getPrevLead = function () {
848
+ }
849
+ getPrevLead() {
871
850
  var _a;
872
- var layoutId = this.options.layoutId;
851
+ const { layoutId } = this.options;
873
852
  return layoutId ? (_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.prevLead : undefined;
874
- };
875
- ProjectionNode.prototype.getStack = function () {
876
- var layoutId = this.options.layoutId;
853
+ }
854
+ getStack() {
855
+ const { layoutId } = this.options;
877
856
  if (layoutId)
878
857
  return this.root.sharedNodes.get(layoutId);
879
- };
880
- ProjectionNode.prototype.promote = function (_a) {
881
- var _b = _a === void 0 ? {} : _a, needsReset = _b.needsReset, transition = _b.transition, preserveFollowOpacity = _b.preserveFollowOpacity;
882
- var stack = this.getStack();
858
+ }
859
+ promote({ needsReset, transition, preserveFollowOpacity, } = {}) {
860
+ const stack = this.getStack();
883
861
  if (stack)
884
862
  stack.promote(this, preserveFollowOpacity);
885
863
  if (needsReset) {
@@ -887,29 +865,29 @@ function createProjectionNode(_a) {
887
865
  this.needsReset = true;
888
866
  }
889
867
  if (transition)
890
- this.setOptions({ transition: transition });
891
- };
892
- ProjectionNode.prototype.relegate = function () {
893
- var stack = this.getStack();
868
+ this.setOptions({ transition });
869
+ }
870
+ relegate() {
871
+ const stack = this.getStack();
894
872
  if (stack) {
895
873
  return stack.relegate(this);
896
874
  }
897
875
  else {
898
876
  return false;
899
877
  }
900
- };
901
- ProjectionNode.prototype.resetRotation = function () {
902
- var visualElement = this.options.visualElement;
878
+ }
879
+ resetRotation() {
880
+ const { visualElement } = this.options;
903
881
  if (!visualElement)
904
882
  return;
905
883
  // If there's no detected rotation values, we can early return without a forced render.
906
- var hasRotate = false;
884
+ let hasRotate = false;
907
885
  // Keep a record of all the values we've reset
908
- var resetValues = {};
886
+ const resetValues = {};
909
887
  // Check the rotate value of all axes and reset to 0
910
- for (var i = 0; i < transformAxes.length; i++) {
911
- var axis = transformAxes[i];
912
- var key = "rotate" + axis;
888
+ for (let i = 0; i < transformAxes.length; i++) {
889
+ const axis = transformAxes[i];
890
+ const key = "rotate" + axis;
913
891
  // If this rotation doesn't exist as a motion value, then we don't
914
892
  // need to reset it
915
893
  if (!visualElement.getStaticValue(key)) {
@@ -927,18 +905,17 @@ function createProjectionNode(_a) {
927
905
  // set to 0.
928
906
  visualElement === null || visualElement === void 0 ? void 0 : visualElement.syncRender();
929
907
  // Put back all the values we reset
930
- for (var key in resetValues) {
908
+ for (const key in resetValues) {
931
909
  visualElement.setStaticValue(key, resetValues[key]);
932
910
  }
933
911
  // Schedule a render for the next frame. This ensures we won't visually
934
912
  // see the element with the reset rotate value applied.
935
913
  visualElement.scheduleRender();
936
- };
937
- ProjectionNode.prototype.getProjectionStyles = function (styleProp) {
914
+ }
915
+ getProjectionStyles(styleProp = {}) {
938
916
  var _a, _b, _c, _d, _e, _f;
939
- if (styleProp === void 0) { styleProp = {}; }
940
917
  // TODO: Return lifecycle-persistent object
941
- var styles = {};
918
+ const styles = {};
942
919
  if (!this.instance || this.isSVG)
943
920
  return styles;
944
921
  if (!this.isVisible) {
@@ -947,7 +924,7 @@ function createProjectionNode(_a) {
947
924
  else {
948
925
  styles.visibility = "";
949
926
  }
950
- var transformTemplate = (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.getProps().transformTemplate;
927
+ const transformTemplate = (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.getProps().transformTemplate;
951
928
  if (this.needsReset) {
952
929
  this.needsReset = false;
953
930
  styles.opacity = "";
@@ -958,9 +935,9 @@ function createProjectionNode(_a) {
958
935
  : "none";
959
936
  return styles;
960
937
  }
961
- var lead = this.getLead();
938
+ const lead = this.getLead();
962
939
  if (!this.projectionDelta || !this.layout || !lead.target) {
963
- var emptyStyles = {};
940
+ const emptyStyles = {};
964
941
  if (this.options.layoutId) {
965
942
  emptyStyles.opacity = (_b = this.latestValues.opacity) !== null && _b !== void 0 ? _b : 1;
966
943
  emptyStyles.pointerEvents =
@@ -974,14 +951,14 @@ function createProjectionNode(_a) {
974
951
  }
975
952
  return emptyStyles;
976
953
  }
977
- var valuesToRender = lead.animationValues || lead.latestValues;
954
+ const valuesToRender = lead.animationValues || lead.latestValues;
978
955
  this.applyTransformsToTarget();
979
956
  styles.transform = buildProjectionTransform(this.projectionDeltaWithTransform, this.treeScale, valuesToRender);
980
957
  if (transformTemplate) {
981
958
  styles.transform = transformTemplate(valuesToRender, styles.transform);
982
959
  }
983
- var _g = this.projectionDelta, x = _g.x, y = _g.y;
984
- styles.transformOrigin = "".concat(x.origin * 100, "% ").concat(y.origin * 100, "% 0");
960
+ const { x, y } = this.projectionDelta;
961
+ styles.transformOrigin = `${x.origin * 100}% ${y.origin * 100}% 0`;
985
962
  if (lead.animationValues) {
986
963
  /**
987
964
  * If the lead component is animating, assign this either the entering/leaving
@@ -1007,14 +984,14 @@ function createProjectionNode(_a) {
1007
984
  /**
1008
985
  * Apply scale correction
1009
986
  */
1010
- for (var key in scaleCorrectors) {
987
+ for (const key in scaleCorrectors) {
1011
988
  if (valuesToRender[key] === undefined)
1012
989
  continue;
1013
- var _h = scaleCorrectors[key], correct = _h.correct, applyTo = _h.applyTo;
1014
- var corrected = correct(valuesToRender[key], lead);
990
+ const { correct, applyTo } = scaleCorrectors[key];
991
+ const corrected = correct(valuesToRender[key], lead);
1015
992
  if (applyTo) {
1016
- var num = applyTo.length;
1017
- for (var i = 0; i < num; i++) {
993
+ const num = applyTo.length;
994
+ for (let i = 0; i < num; i++) {
1018
995
  styles[applyTo[i]] = corrected;
1019
996
  }
1020
997
  }
@@ -1034,62 +1011,61 @@ function createProjectionNode(_a) {
1034
1011
  : "none";
1035
1012
  }
1036
1013
  return styles;
1037
- };
1038
- ProjectionNode.prototype.clearSnapshot = function () {
1014
+ }
1015
+ clearSnapshot() {
1039
1016
  this.resumeFrom = this.snapshot = undefined;
1040
- };
1017
+ }
1041
1018
  // Only run on root
1042
- ProjectionNode.prototype.resetTree = function () {
1043
- this.root.nodes.forEach(function (node) { var _a; return (_a = node.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop(); });
1019
+ resetTree() {
1020
+ this.root.nodes.forEach((node) => { var _a; return (_a = node.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop(); });
1044
1021
  this.root.nodes.forEach(clearMeasurements);
1045
1022
  this.root.sharedNodes.clear();
1046
- };
1047
- return ProjectionNode;
1048
- }());
1023
+ }
1024
+ };
1049
1025
  }
1050
1026
  function updateLayout(node) {
1051
1027
  node.updateLayout();
1052
1028
  }
1053
1029
  function notifyLayoutUpdate(node) {
1054
1030
  var _a, _b, _c, _d;
1055
- var snapshot = (_b = (_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) !== null && _b !== void 0 ? _b : node.snapshot;
1031
+ const snapshot = (_b = (_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) !== null && _b !== void 0 ? _b : node.snapshot;
1056
1032
  if (node.isLead() &&
1057
1033
  node.layout &&
1058
1034
  snapshot &&
1059
1035
  node.hasListeners("didUpdate")) {
1060
- var _e = node.layout, layout_1 = _e.actual, measuredLayout = _e.measured;
1036
+ const { actual: layout, measured: measuredLayout } = node.layout;
1061
1037
  // TODO Maybe we want to also resize the layout snapshot so we don't trigger
1062
1038
  // animations for instance if layout="size" and an element has only changed position
1063
1039
  if (node.options.animationType === "size") {
1064
- eachAxis(function (axis) {
1065
- var axisSnapshot = snapshot.isShared
1040
+ eachAxis((axis) => {
1041
+ const axisSnapshot = snapshot.isShared
1066
1042
  ? snapshot.measured[axis]
1067
1043
  : snapshot.layout[axis];
1068
- var length = calcLength(axisSnapshot);
1069
- axisSnapshot.min = layout_1[axis].min;
1044
+ const length = calcLength(axisSnapshot);
1045
+ axisSnapshot.min = layout[axis].min;
1070
1046
  axisSnapshot.max = axisSnapshot.min + length;
1071
1047
  });
1072
1048
  }
1073
1049
  else if (node.options.animationType === "position") {
1074
- eachAxis(function (axis) {
1075
- var axisSnapshot = snapshot.isShared
1050
+ eachAxis((axis) => {
1051
+ const axisSnapshot = snapshot.isShared
1076
1052
  ? snapshot.measured[axis]
1077
1053
  : snapshot.layout[axis];
1078
- var length = calcLength(layout_1[axis]);
1054
+ const length = calcLength(layout[axis]);
1079
1055
  axisSnapshot.max = axisSnapshot.min + length;
1080
1056
  });
1081
1057
  }
1082
- var layoutDelta = createDelta();
1083
- calcBoxDelta(layoutDelta, layout_1, snapshot.layout);
1084
- var visualDelta = createDelta();
1058
+ const layoutDelta = createDelta();
1059
+ calcBoxDelta(layoutDelta, layout, snapshot.layout);
1060
+ const visualDelta = createDelta();
1085
1061
  if (snapshot.isShared) {
1086
1062
  calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measured);
1087
1063
  }
1088
1064
  else {
1089
- calcBoxDelta(visualDelta, layout_1, snapshot.layout);
1065
+ calcBoxDelta(visualDelta, layout, snapshot.layout);
1090
1066
  }
1091
- var hasLayoutChanged = !isDeltaZero(layoutDelta);
1092
- var hasRelativeTargetChanged = false;
1067
+ const hasLayoutChanged = !isDeltaZero(layoutDelta);
1068
+ let hasRelativeTargetChanged = false;
1093
1069
  if (!node.resumeFrom) {
1094
1070
  node.relativeParent = node.getClosestProjectingParent();
1095
1071
  /**
@@ -1097,12 +1073,12 @@ function notifyLayoutUpdate(node) {
1097
1073
  * the relative snapshot is not relavent
1098
1074
  */
1099
1075
  if (node.relativeParent && !node.relativeParent.resumeFrom) {
1100
- var _f = node.relativeParent, parentSnapshot = _f.snapshot, parentLayout = _f.layout;
1076
+ const { snapshot: parentSnapshot, layout: parentLayout } = node.relativeParent;
1101
1077
  if (parentSnapshot && parentLayout) {
1102
- var relativeSnapshot = createBox();
1078
+ const relativeSnapshot = createBox();
1103
1079
  calcRelativePosition(relativeSnapshot, snapshot.layout, parentSnapshot.layout);
1104
- var relativeLayout = createBox();
1105
- calcRelativePosition(relativeLayout, layout_1, parentLayout.actual);
1080
+ const relativeLayout = createBox();
1081
+ calcRelativePosition(relativeLayout, layout, parentLayout.actual);
1106
1082
  if (!boxEquals(relativeSnapshot, relativeLayout)) {
1107
1083
  hasRelativeTargetChanged = true;
1108
1084
  }
@@ -1110,12 +1086,12 @@ function notifyLayoutUpdate(node) {
1110
1086
  }
1111
1087
  }
1112
1088
  node.notifyListeners("didUpdate", {
1113
- layout: layout_1,
1114
- snapshot: snapshot,
1089
+ layout,
1090
+ snapshot,
1115
1091
  delta: visualDelta,
1116
- layoutDelta: layoutDelta,
1117
- hasLayoutChanged: hasLayoutChanged,
1118
- hasRelativeTargetChanged: hasRelativeTargetChanged,
1092
+ layoutDelta,
1093
+ hasLayoutChanged,
1094
+ hasRelativeTargetChanged,
1119
1095
  });
1120
1096
  }
1121
1097
  else if (node.isLead()) {
@@ -1135,7 +1111,7 @@ function clearMeasurements(node) {
1135
1111
  node.clearMeasurements();
1136
1112
  }
1137
1113
  function resetTransformStyle(node) {
1138
- var visualElement = node.options.visualElement;
1114
+ const { visualElement } = node.options;
1139
1115
  if (visualElement === null || visualElement === void 0 ? void 0 : visualElement.getProps().onBeforeLayoutMeasure) {
1140
1116
  visualElement.notifyBeforeLayoutMeasure();
1141
1117
  }
@@ -1174,7 +1150,7 @@ function mixBox(output, from, to, p) {
1174
1150
  function hasOpacityCrossfade(node) {
1175
1151
  return (node.animationValues && node.animationValues.opacityExit !== undefined);
1176
1152
  }
1177
- var defaultLayoutTransition = {
1153
+ const defaultLayoutTransition = {
1178
1154
  duration: 0.45,
1179
1155
  ease: [0.4, 0, 0.1, 1],
1180
1156
  };
@@ -1183,15 +1159,15 @@ function mountNodeEarly(node, id) {
1183
1159
  * Rather than searching the DOM from document we can search the
1184
1160
  * path for the deepest mounted ancestor and search from there
1185
1161
  */
1186
- var searchNode = node.root;
1187
- for (var i = node.path.length - 1; i >= 0; i--) {
1162
+ let searchNode = node.root;
1163
+ for (let i = node.path.length - 1; i >= 0; i--) {
1188
1164
  if (Boolean(node.path[i].instance)) {
1189
1165
  searchNode = node.path[i];
1190
1166
  break;
1191
1167
  }
1192
1168
  }
1193
- var searchElement = searchNode && searchNode !== node.root ? searchNode.instance : document;
1194
- var element = searchElement.querySelector("[data-projection-id=\"".concat(id, "\"]"));
1169
+ const searchElement = searchNode && searchNode !== node.root ? searchNode.instance : document;
1170
+ const element = searchElement.querySelector(`[data-projection-id="${id}"]`);
1195
1171
  if (element)
1196
1172
  node.mount(element, true);
1197
1173
  }