motion 10.18.0 → 11.11.13

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 (384) hide show
  1. package/.turbo/turbo-build.log +32 -0
  2. package/{LICENSE → LICENSE.md} +2 -2
  3. package/README.md +99 -7
  4. package/dist/cjs/index.js +6117 -0
  5. package/dist/cjs/react-client.js +10003 -0
  6. package/dist/cjs/react-m.js +1852 -0
  7. package/dist/es/framer-motion/dist/es/animation/GroupPlaybackControls.mjs +78 -0
  8. package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +34 -0
  9. package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +19 -0
  10. package/dist/es/framer-motion/dist/es/animation/animate/sequence.mjs +14 -0
  11. package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +11 -0
  12. package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +52 -0
  13. package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +318 -0
  14. package/dist/es/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +113 -0
  15. package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +384 -0
  16. package/dist/es/framer-motion/dist/es/animation/animators/drivers/driver-frameloop.mjs +17 -0
  17. package/dist/es/framer-motion/dist/es/animation/animators/utils/accelerated-values.mjs +14 -0
  18. package/dist/es/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +42 -0
  19. package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +169 -0
  20. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +36 -0
  21. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +12 -0
  22. package/dist/es/framer-motion/dist/es/animation/animators/waapi/easing.mjs +44 -0
  23. package/dist/es/framer-motion/dist/es/animation/animators/waapi/index.mjs +23 -0
  24. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/attach-timeline.mjs +6 -0
  25. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/get-final-keyframe.mjs +12 -0
  26. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/linear.mjs +15 -0
  27. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/memo-supports.mjs +9 -0
  28. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/style.mjs +8 -0
  29. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-flags.mjs +9 -0
  30. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs +15 -0
  31. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +13 -0
  32. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +5 -0
  33. package/dist/es/framer-motion/dist/es/animation/generators/inertia.mjs +87 -0
  34. package/dist/es/framer-motion/dist/es/animation/generators/keyframes.mjs +51 -0
  35. package/dist/es/framer-motion/dist/es/animation/generators/spring/find.mjs +89 -0
  36. package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +129 -0
  37. package/dist/es/framer-motion/dist/es/animation/generators/utils/calc-duration.mjs +17 -0
  38. package/dist/es/framer-motion/dist/es/animation/generators/utils/is-generator.mjs +5 -0
  39. package/dist/es/framer-motion/dist/es/animation/generators/utils/velocity.mjs +9 -0
  40. package/dist/es/framer-motion/dist/es/animation/hooks/animation-controls.mjs +80 -0
  41. package/dist/es/framer-motion/dist/es/animation/hooks/use-animate-style.mjs +17 -0
  42. package/dist/es/framer-motion/dist/es/animation/hooks/use-animate.mjs +17 -0
  43. package/dist/es/framer-motion/dist/es/animation/hooks/use-animated-state.mjs +64 -0
  44. package/dist/es/framer-motion/dist/es/animation/hooks/use-animation.mjs +41 -0
  45. package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +113 -0
  46. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +75 -0
  47. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-variant.mjs +66 -0
  48. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element.mjs +26 -0
  49. package/dist/es/framer-motion/dist/es/animation/optimized-appear/data-id.mjs +6 -0
  50. package/dist/es/framer-motion/dist/es/animation/optimized-appear/get-appear-id.mjs +7 -0
  51. package/dist/es/framer-motion/dist/es/animation/optimized-appear/handoff.mjs +40 -0
  52. package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +173 -0
  53. package/dist/es/framer-motion/dist/es/animation/optimized-appear/store-id.mjs +8 -0
  54. package/dist/es/framer-motion/dist/es/animation/optimized-appear/store.mjs +4 -0
  55. package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +230 -0
  56. package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-time.mjs +21 -0
  57. package/dist/es/framer-motion/dist/es/animation/sequence/utils/edit.mjs +31 -0
  58. package/dist/es/framer-motion/dist/es/animation/sequence/utils/sort.mjs +14 -0
  59. package/dist/es/framer-motion/dist/es/animation/utils/create-visual-element.mjs +44 -0
  60. package/dist/es/framer-motion/dist/es/animation/utils/default-transitions.mjs +40 -0
  61. package/dist/es/framer-motion/dist/es/animation/utils/get-value-transition.mjs +9 -0
  62. package/dist/es/framer-motion/dist/es/animation/utils/is-animatable.mjs +30 -0
  63. package/dist/es/framer-motion/dist/es/animation/utils/is-animation-controls.mjs +7 -0
  64. package/dist/es/framer-motion/dist/es/animation/utils/is-dom-keyframes.mjs +5 -0
  65. package/dist/es/framer-motion/dist/es/animation/utils/is-keyframes-target.mjs +5 -0
  66. package/dist/es/framer-motion/dist/es/animation/utils/is-none.mjs +15 -0
  67. package/dist/es/framer-motion/dist/es/animation/utils/is-transition-defined.mjs +10 -0
  68. package/dist/es/framer-motion/dist/es/animation/utils/stagger.mjs +26 -0
  69. package/dist/es/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs +77 -0
  70. package/dist/es/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs +61 -0
  71. package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +163 -0
  72. package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs +66 -0
  73. package/dist/es/framer-motion/dist/es/components/AnimatePresence/utils.mjs +14 -0
  74. package/dist/es/framer-motion/dist/es/components/AnimateSharedLayout.mjs +15 -0
  75. package/dist/es/framer-motion/dist/es/components/LayoutGroup/index.mjs +32 -0
  76. package/dist/es/framer-motion/dist/es/components/LazyMotion/index.mjs +68 -0
  77. package/dist/es/framer-motion/dist/es/components/MotionConfig/index.mjs +48 -0
  78. package/dist/es/framer-motion/dist/es/components/Reorder/Group.mjs +53 -0
  79. package/dist/es/framer-motion/dist/es/components/Reorder/Item.mjs +34 -0
  80. package/dist/es/framer-motion/dist/es/components/Reorder/namespace.mjs +2 -0
  81. package/dist/es/framer-motion/dist/es/components/Reorder/utils/check-reorder.mjs +24 -0
  82. package/dist/es/framer-motion/dist/es/context/DeprecatedLayoutGroupContext.mjs +10 -0
  83. package/dist/es/framer-motion/dist/es/context/LayoutGroupContext.mjs +6 -0
  84. package/dist/es/framer-motion/dist/es/context/LazyContext.mjs +6 -0
  85. package/dist/es/framer-motion/dist/es/context/MotionConfigContext.mjs +13 -0
  86. package/dist/es/framer-motion/dist/es/context/MotionContext/create.mjs +13 -0
  87. package/dist/es/framer-motion/dist/es/context/MotionContext/index.mjs +6 -0
  88. package/dist/es/framer-motion/dist/es/context/MotionContext/utils.mjs +17 -0
  89. package/dist/es/framer-motion/dist/es/context/PresenceContext.mjs +9 -0
  90. package/dist/es/framer-motion/dist/es/context/ReorderContext.mjs +6 -0
  91. package/dist/es/framer-motion/dist/es/context/SwitchLayoutGroupContext.mjs +9 -0
  92. package/dist/es/framer-motion/dist/es/easing/anticipate.mjs +5 -0
  93. package/dist/es/framer-motion/dist/es/easing/back.mjs +9 -0
  94. package/dist/es/framer-motion/dist/es/easing/circ.mjs +8 -0
  95. package/dist/es/framer-motion/dist/es/easing/cubic-bezier.mjs +51 -0
  96. package/dist/es/framer-motion/dist/es/easing/ease.mjs +7 -0
  97. package/dist/es/framer-motion/dist/es/easing/modifiers/mirror.mjs +5 -0
  98. package/dist/es/framer-motion/dist/es/easing/modifiers/reverse.mjs +5 -0
  99. package/dist/es/framer-motion/dist/es/easing/steps.mjs +15 -0
  100. package/dist/es/framer-motion/dist/es/easing/utils/create-generator-easing.mjs +17 -0
  101. package/dist/es/framer-motion/dist/es/easing/utils/get-easing-for-segment.mjs +8 -0
  102. package/dist/es/framer-motion/dist/es/easing/utils/is-bezier-definition.mjs +3 -0
  103. package/dist/es/framer-motion/dist/es/easing/utils/is-easing-array.mjs +5 -0
  104. package/dist/es/framer-motion/dist/es/easing/utils/map.mjs +38 -0
  105. package/dist/es/framer-motion/dist/es/events/add-dom-event.mjs +6 -0
  106. package/dist/es/framer-motion/dist/es/events/add-pointer-event.mjs +8 -0
  107. package/dist/es/framer-motion/dist/es/events/event-info.mjs +15 -0
  108. package/dist/es/framer-motion/dist/es/events/use-dom-event.mjs +34 -0
  109. package/dist/es/framer-motion/dist/es/events/utils/is-primary-pointer.mjs +18 -0
  110. package/dist/es/framer-motion/dist/es/frameloop/batcher.mjs +74 -0
  111. package/dist/es/framer-motion/dist/es/frameloop/frame.mjs +6 -0
  112. package/dist/es/framer-motion/dist/es/frameloop/index-legacy.mjs +20 -0
  113. package/dist/es/framer-motion/dist/es/frameloop/microtask.mjs +5 -0
  114. package/dist/es/framer-motion/dist/es/frameloop/render-step.mjs +80 -0
  115. package/dist/es/framer-motion/dist/es/frameloop/sync-time.mjs +31 -0
  116. package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +487 -0
  117. package/dist/es/framer-motion/dist/es/gestures/drag/index.mjs +27 -0
  118. package/dist/es/framer-motion/dist/es/gestures/drag/use-drag-controls.mjs +88 -0
  119. package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +129 -0
  120. package/dist/es/framer-motion/dist/es/gestures/drag/utils/lock.mjs +53 -0
  121. package/dist/es/framer-motion/dist/es/gestures/focus.mjs +41 -0
  122. package/dist/es/framer-motion/dist/es/gestures/hover.mjs +33 -0
  123. package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +156 -0
  124. package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +50 -0
  125. package/dist/es/framer-motion/dist/es/gestures/press.mjs +130 -0
  126. package/dist/es/framer-motion/dist/es/gestures/utils/is-node-or-child.mjs +20 -0
  127. package/dist/es/framer-motion/dist/es/motion/features/Feature.mjs +9 -0
  128. package/dist/es/framer-motion/dist/es/motion/features/animation/exit.mjs +31 -0
  129. package/dist/es/framer-motion/dist/es/motion/features/animation/index.mjs +41 -0
  130. package/dist/es/framer-motion/dist/es/motion/features/animations.mjs +13 -0
  131. package/dist/es/framer-motion/dist/es/motion/features/definitions.mjs +28 -0
  132. package/dist/es/framer-motion/dist/es/motion/features/drag.mjs +17 -0
  133. package/dist/es/framer-motion/dist/es/motion/features/gestures.mjs +21 -0
  134. package/dist/es/framer-motion/dist/es/motion/features/layout/MeasureLayout.mjs +134 -0
  135. package/dist/es/framer-motion/dist/es/motion/features/layout.mjs +11 -0
  136. package/dist/es/framer-motion/dist/es/motion/features/load-features.mjs +12 -0
  137. package/dist/es/framer-motion/dist/es/motion/features/viewport/index.mjs +72 -0
  138. package/dist/es/framer-motion/dist/es/motion/features/viewport/observers.mjs +49 -0
  139. package/dist/es/framer-motion/dist/es/motion/index.mjs +98 -0
  140. package/dist/es/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +11 -0
  141. package/dist/es/framer-motion/dist/es/motion/utils/is-motion-component.mjs +12 -0
  142. package/dist/es/framer-motion/dist/es/motion/utils/symbol.mjs +3 -0
  143. package/dist/es/framer-motion/dist/es/motion/utils/unwrap-motion-component.mjs +17 -0
  144. package/dist/es/framer-motion/dist/es/motion/utils/use-motion-ref.mjs +36 -0
  145. package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +134 -0
  146. package/dist/es/framer-motion/dist/es/motion/utils/use-visual-state.mjs +82 -0
  147. package/dist/es/framer-motion/dist/es/motion/utils/valid-prop.mjs +57 -0
  148. package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +93 -0
  149. package/dist/es/framer-motion/dist/es/projection/geometry/conversion.mjs +33 -0
  150. package/dist/es/framer-motion/dist/es/projection/geometry/copy.mjs +31 -0
  151. package/dist/es/framer-motion/dist/es/projection/geometry/delta-apply.mjs +119 -0
  152. package/dist/es/framer-motion/dist/es/projection/geometry/delta-calc.mjs +52 -0
  153. package/dist/es/framer-motion/dist/es/projection/geometry/delta-remove.mjs +54 -0
  154. package/dist/es/framer-motion/dist/es/projection/geometry/models.mjs +17 -0
  155. package/dist/es/framer-motion/dist/es/projection/geometry/utils.mjs +31 -0
  156. package/dist/es/framer-motion/dist/es/projection/node/DocumentProjectionNode.mjs +13 -0
  157. package/dist/es/framer-motion/dist/es/projection/node/HTMLProjectionNode.mjs +27 -0
  158. package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +1583 -0
  159. package/dist/es/framer-motion/dist/es/projection/node/group.mjs +24 -0
  160. package/dist/es/framer-motion/dist/es/projection/node/state.mjs +19 -0
  161. package/dist/es/framer-motion/dist/es/projection/shared/stack.mjs +112 -0
  162. package/dist/es/framer-motion/dist/es/projection/styles/scale-border-radius.mjs +41 -0
  163. package/dist/es/framer-motion/dist/es/projection/styles/scale-box-shadow.mjs +35 -0
  164. package/dist/es/framer-motion/dist/es/projection/styles/scale-correction.mjs +6 -0
  165. package/dist/es/framer-motion/dist/es/projection/styles/transform.mjs +49 -0
  166. package/dist/es/framer-motion/dist/es/projection/use-instant-layout-transition.mjs +14 -0
  167. package/dist/es/framer-motion/dist/es/projection/use-reset-projection.mjs +14 -0
  168. package/dist/es/framer-motion/dist/es/projection/utils/each-axis.mjs +5 -0
  169. package/dist/es/framer-motion/dist/es/projection/utils/has-transform.mjs +26 -0
  170. package/dist/es/framer-motion/dist/es/projection/utils/measure.mjs +17 -0
  171. package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +477 -0
  172. package/dist/es/framer-motion/dist/es/render/components/create-factory.mjs +23 -0
  173. package/dist/es/framer-motion/dist/es/render/components/create-proxy.mjs +38 -0
  174. package/dist/es/framer-motion/dist/es/render/components/m/create.mjs +6 -0
  175. package/dist/es/framer-motion/dist/es/render/components/m/elements.mjs +227 -0
  176. package/dist/es/framer-motion/dist/es/render/components/m/proxy.mjs +6 -0
  177. package/dist/es/framer-motion/dist/es/render/components/motion/create.mjs +15 -0
  178. package/dist/es/framer-motion/dist/es/render/components/motion/elements.mjs +194 -0
  179. package/dist/es/framer-motion/dist/es/render/components/motion/proxy.mjs +6 -0
  180. package/dist/es/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +130 -0
  181. package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +28 -0
  182. package/dist/es/framer-motion/dist/es/render/dom/create-visual-element.mjs +14 -0
  183. package/dist/es/framer-motion/dist/es/render/dom/features-animation.mjs +14 -0
  184. package/dist/es/framer-motion/dist/es/render/dom/features-max.mjs +14 -0
  185. package/dist/es/framer-motion/dist/es/render/dom/features-min.mjs +12 -0
  186. package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +64 -0
  187. package/dist/es/framer-motion/dist/es/render/dom/resize/handle-window.mjs +30 -0
  188. package/dist/es/framer-motion/dist/es/render/dom/resize/index.mjs +8 -0
  189. package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +80 -0
  190. package/dist/es/framer-motion/dist/es/render/dom/scroll/info.mjs +56 -0
  191. package/dist/es/framer-motion/dist/es/render/dom/scroll/observe.mjs +18 -0
  192. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/edge.mjs +45 -0
  193. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +59 -0
  194. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/inset.mjs +45 -0
  195. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/offset.mjs +35 -0
  196. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/presets.mjs +20 -0
  197. package/dist/es/framer-motion/dist/es/render/dom/scroll/on-scroll-handler.mjs +48 -0
  198. package/dist/es/framer-motion/dist/es/render/dom/scroll/supports.mjs +5 -0
  199. package/dist/es/framer-motion/dist/es/render/dom/scroll/track.mjs +84 -0
  200. package/dist/es/framer-motion/dist/es/render/dom/use-render.mjs +33 -0
  201. package/dist/es/framer-motion/dist/es/render/dom/utils/camel-to-dash.mjs +6 -0
  202. package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +42 -0
  203. package/dist/es/framer-motion/dist/es/render/dom/utils/filter-props.mjs +59 -0
  204. package/dist/es/framer-motion/dist/es/render/dom/utils/is-css-variable.mjs +15 -0
  205. package/dist/es/framer-motion/dist/es/render/dom/utils/is-svg-component.mjs +30 -0
  206. package/dist/es/framer-motion/dist/es/render/dom/utils/is-svg-element.mjs +5 -0
  207. package/dist/es/framer-motion/dist/es/render/dom/utils/resolve-element.mjs +28 -0
  208. package/dist/es/framer-motion/dist/es/render/dom/utils/unit-conversion.mjs +65 -0
  209. package/dist/es/framer-motion/dist/es/render/dom/value-types/animatable-none.mjs +15 -0
  210. package/dist/es/framer-motion/dist/es/render/dom/value-types/defaults.mjs +30 -0
  211. package/dist/es/framer-motion/dist/es/render/dom/value-types/dimensions.mjs +15 -0
  212. package/dist/es/framer-motion/dist/es/render/dom/value-types/find.mjs +15 -0
  213. package/dist/es/framer-motion/dist/es/render/dom/value-types/get-as-type.mjs +10 -0
  214. package/dist/es/framer-motion/dist/es/render/dom/value-types/number-browser.mjs +41 -0
  215. package/dist/es/framer-motion/dist/es/render/dom/value-types/number.mjs +18 -0
  216. package/dist/es/framer-motion/dist/es/render/dom/value-types/test.mjs +6 -0
  217. package/dist/es/framer-motion/dist/es/render/dom/value-types/transform.mjs +31 -0
  218. package/dist/es/framer-motion/dist/es/render/dom/value-types/type-auto.mjs +9 -0
  219. package/dist/es/framer-motion/dist/es/render/dom/value-types/type-int.mjs +8 -0
  220. package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +43 -0
  221. package/dist/es/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +57 -0
  222. package/dist/es/framer-motion/dist/es/render/html/config-motion.mjs +12 -0
  223. package/dist/es/framer-motion/dist/es/render/html/use-props.mjs +57 -0
  224. package/dist/es/framer-motion/dist/es/render/html/utils/build-styles.mjs +65 -0
  225. package/dist/es/framer-motion/dist/es/render/html/utils/build-transform.mjs +62 -0
  226. package/dist/es/framer-motion/dist/es/render/html/utils/create-render-state.mjs +8 -0
  227. package/dist/es/framer-motion/dist/es/render/html/utils/make-none-animatable.mjs +30 -0
  228. package/dist/es/framer-motion/dist/es/render/html/utils/render.mjs +9 -0
  229. package/dist/es/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +20 -0
  230. package/dist/es/framer-motion/dist/es/render/html/utils/transform.mjs +28 -0
  231. package/dist/es/framer-motion/dist/es/render/object/ObjectVisualElement.mjs +41 -0
  232. package/dist/es/framer-motion/dist/es/render/store.mjs +3 -0
  233. package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +45 -0
  234. package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +40 -0
  235. package/dist/es/framer-motion/dist/es/render/svg/lowercase-elements.mjs +33 -0
  236. package/dist/es/framer-motion/dist/es/render/svg/use-props.mjs +24 -0
  237. package/dist/es/framer-motion/dist/es/render/svg/utils/build-attrs.mjs +52 -0
  238. package/dist/es/framer-motion/dist/es/render/svg/utils/camel-case-attrs.mjs +30 -0
  239. package/dist/es/framer-motion/dist/es/render/svg/utils/create-render-state.mjs +8 -0
  240. package/dist/es/framer-motion/dist/es/render/svg/utils/is-svg-tag.mjs +3 -0
  241. package/dist/es/framer-motion/dist/es/render/svg/utils/path.mjs +32 -0
  242. package/dist/es/framer-motion/dist/es/render/svg/utils/render.mjs +12 -0
  243. package/dist/es/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +19 -0
  244. package/dist/es/framer-motion/dist/es/render/svg/utils/transform-origin.mjs +18 -0
  245. package/dist/es/framer-motion/dist/es/render/utils/KeyframesResolver.mjs +164 -0
  246. package/dist/es/framer-motion/dist/es/render/utils/animation-state.mjs +332 -0
  247. package/dist/es/framer-motion/dist/es/render/utils/compare-by-depth.mjs +3 -0
  248. package/dist/es/framer-motion/dist/es/render/utils/flat-tree.mjs +24 -0
  249. package/dist/es/framer-motion/dist/es/render/utils/get-variant-context.mjs +28 -0
  250. package/dist/es/framer-motion/dist/es/render/utils/is-controlling-variants.mjs +13 -0
  251. package/dist/es/framer-motion/dist/es/render/utils/is-variant-label.mjs +8 -0
  252. package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +59 -0
  253. package/dist/es/framer-motion/dist/es/render/utils/resolve-dynamic-variants.mjs +8 -0
  254. package/dist/es/framer-motion/dist/es/render/utils/resolve-variants.mjs +36 -0
  255. package/dist/es/framer-motion/dist/es/render/utils/setters.mjs +27 -0
  256. package/dist/es/framer-motion/dist/es/render/utils/variant-props.mjs +12 -0
  257. package/dist/es/framer-motion/dist/es/utils/GlobalConfig.mjs +6 -0
  258. package/dist/es/framer-motion/dist/es/utils/array.mjs +21 -0
  259. package/dist/es/framer-motion/dist/es/utils/clamp.mjs +9 -0
  260. package/dist/es/framer-motion/dist/es/utils/delay.mjs +24 -0
  261. package/dist/es/framer-motion/dist/es/utils/distance.mjs +9 -0
  262. package/dist/es/framer-motion/dist/es/utils/errors.mjs +18 -0
  263. package/dist/es/framer-motion/dist/es/utils/get-context-window.mjs +6 -0
  264. package/dist/es/framer-motion/dist/es/utils/hsla-to-rgba.mjs +42 -0
  265. package/dist/es/framer-motion/dist/es/utils/interpolate.mjs +75 -0
  266. package/dist/es/framer-motion/dist/es/utils/is-browser.mjs +3 -0
  267. package/dist/es/framer-motion/dist/es/utils/is-numerical-string.mjs +6 -0
  268. package/dist/es/framer-motion/dist/es/utils/is-ref-object.mjs +7 -0
  269. package/dist/es/framer-motion/dist/es/utils/is-zero-value-string.mjs +6 -0
  270. package/dist/es/framer-motion/dist/es/utils/memo.mjs +10 -0
  271. package/dist/es/framer-motion/dist/es/utils/mix/color.mjs +47 -0
  272. package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +94 -0
  273. package/dist/es/framer-motion/dist/es/utils/mix/immediate.mjs +5 -0
  274. package/dist/es/framer-motion/dist/es/utils/mix/index.mjs +14 -0
  275. package/dist/es/framer-motion/dist/es/utils/mix/number.mjs +26 -0
  276. package/dist/es/framer-motion/dist/es/utils/mix/visibility.mjs +16 -0
  277. package/dist/es/framer-motion/dist/es/utils/noop.mjs +3 -0
  278. package/dist/es/framer-motion/dist/es/utils/offsets/default.mjs +9 -0
  279. package/dist/es/framer-motion/dist/es/utils/offsets/fill.mjs +12 -0
  280. package/dist/es/framer-motion/dist/es/utils/offsets/time.mjs +5 -0
  281. package/dist/es/framer-motion/dist/es/utils/pipe.mjs +11 -0
  282. package/dist/es/framer-motion/dist/es/utils/progress.mjs +18 -0
  283. package/dist/es/framer-motion/dist/es/utils/reduced-motion/index.mjs +19 -0
  284. package/dist/es/framer-motion/dist/es/utils/reduced-motion/state.mjs +5 -0
  285. package/dist/es/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion-config.mjs +19 -0
  286. package/dist/es/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.mjs +47 -0
  287. package/dist/es/framer-motion/dist/es/utils/resolve-value.mjs +11 -0
  288. package/dist/es/framer-motion/dist/es/utils/shallow-compare.mjs +14 -0
  289. package/dist/es/framer-motion/dist/es/utils/subscription-manager.mjs +40 -0
  290. package/dist/es/framer-motion/dist/es/utils/time-conversion.mjs +10 -0
  291. package/dist/es/framer-motion/dist/es/utils/transform.mjs +21 -0
  292. package/dist/es/framer-motion/dist/es/utils/use-animation-frame.mjs +21 -0
  293. package/dist/es/framer-motion/dist/es/utils/use-constant.mjs +18 -0
  294. package/dist/es/framer-motion/dist/es/utils/use-cycle.mjs +47 -0
  295. package/dist/es/framer-motion/dist/es/utils/use-force-update.mjs +19 -0
  296. package/dist/es/framer-motion/dist/es/utils/use-in-view.mjs +23 -0
  297. package/dist/es/framer-motion/dist/es/utils/use-instant-transition-state.mjs +5 -0
  298. package/dist/es/framer-motion/dist/es/utils/use-instant-transition.mjs +41 -0
  299. package/dist/es/framer-motion/dist/es/utils/use-is-mounted.mjs +15 -0
  300. package/dist/es/framer-motion/dist/es/utils/use-isomorphic-effect.mjs +6 -0
  301. package/dist/es/framer-motion/dist/es/utils/use-motion-value-event.mjs +13 -0
  302. package/dist/es/framer-motion/dist/es/utils/use-unmount-effect.mjs +7 -0
  303. package/dist/es/framer-motion/dist/es/utils/velocity-per-second.mjs +11 -0
  304. package/dist/es/framer-motion/dist/es/utils/warn-once.mjs +11 -0
  305. package/dist/es/framer-motion/dist/es/utils/wrap.mjs +6 -0
  306. package/dist/es/framer-motion/dist/es/value/index.mjs +319 -0
  307. package/dist/es/framer-motion/dist/es/value/scroll/use-element-scroll.mjs +14 -0
  308. package/dist/es/framer-motion/dist/es/value/scroll/use-viewport-scroll.mjs +14 -0
  309. package/dist/es/framer-motion/dist/es/value/types/color/hex.mjs +40 -0
  310. package/dist/es/framer-motion/dist/es/value/types/color/hsla.mjs +22 -0
  311. package/dist/es/framer-motion/dist/es/value/types/color/index.mjs +27 -0
  312. package/dist/es/framer-motion/dist/es/value/types/color/rgba.mjs +25 -0
  313. package/dist/es/framer-motion/dist/es/value/types/color/utils.mjs +29 -0
  314. package/dist/es/framer-motion/dist/es/value/types/complex/filter.mjs +30 -0
  315. package/dist/es/framer-motion/dist/es/value/types/complex/index.mjs +92 -0
  316. package/dist/es/framer-motion/dist/es/value/types/numbers/index.mjs +17 -0
  317. package/dist/es/framer-motion/dist/es/value/types/numbers/units.mjs +17 -0
  318. package/dist/es/framer-motion/dist/es/value/types/utils/color-regex.mjs +3 -0
  319. package/dist/es/framer-motion/dist/es/value/types/utils/float-regex.mjs +3 -0
  320. package/dist/es/framer-motion/dist/es/value/types/utils/is-nullish.mjs +5 -0
  321. package/dist/es/framer-motion/dist/es/value/types/utils/sanitize.mjs +5 -0
  322. package/dist/es/framer-motion/dist/es/value/types/utils/single-color-regex.mjs +3 -0
  323. package/dist/es/framer-motion/dist/es/value/use-combine-values.mjs +37 -0
  324. package/dist/es/framer-motion/dist/es/value/use-computed.mjs +19 -0
  325. package/dist/es/framer-motion/dist/es/value/use-inverted-scale.mjs +52 -0
  326. package/dist/es/framer-motion/dist/es/value/use-motion-template.mjs +45 -0
  327. package/dist/es/framer-motion/dist/es/value/use-motion-value.mjs +38 -0
  328. package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +39 -0
  329. package/dist/es/framer-motion/dist/es/value/use-spring.mjs +85 -0
  330. package/dist/es/framer-motion/dist/es/value/use-time.mjs +10 -0
  331. package/dist/es/framer-motion/dist/es/value/use-transform.mjs +29 -0
  332. package/dist/es/framer-motion/dist/es/value/use-velocity.mjs +35 -0
  333. package/dist/es/framer-motion/dist/es/value/use-will-change/WillChangeMotionValue.mjs +22 -0
  334. package/dist/es/framer-motion/dist/es/value/use-will-change/add-will-change.mjs +14 -0
  335. package/dist/es/framer-motion/dist/es/value/use-will-change/get-will-change-name.mjs +14 -0
  336. package/dist/es/framer-motion/dist/es/value/use-will-change/index.mjs +8 -0
  337. package/dist/es/framer-motion/dist/es/value/use-will-change/is.mjs +7 -0
  338. package/dist/es/framer-motion/dist/es/value/utils/is-motion-value.mjs +3 -0
  339. package/dist/es/framer-motion/dist/es/value/utils/resolve-motion-value.mjs +16 -0
  340. package/dist/es/motion/lib/index.mjs +30 -0
  341. package/dist/es/motion/lib/react-client.mjs +3 -0
  342. package/dist/es/motion/lib/react-m.mjs +3 -0
  343. package/dist/es/motion/lib/react.mjs +110 -0
  344. package/dist/index.d.ts +1 -0
  345. package/dist/motion.dev.js +6121 -0
  346. package/dist/motion.js +1 -0
  347. package/dist/react-client.d.ts +1 -0
  348. package/dist/react-m.d.ts +1 -0
  349. package/dist/react.d.ts +1 -0
  350. package/lib/index.js +1 -3
  351. package/lib/index.js.map +1 -1
  352. package/lib/react-client.js +3 -0
  353. package/lib/react-client.js.map +1 -0
  354. package/lib/react-m.js +3 -0
  355. package/lib/react-m.js.map +1 -0
  356. package/lib/react.js +3 -0
  357. package/lib/react.js.map +1 -0
  358. package/package.json +79 -29
  359. package/react/package.json +6 -0
  360. package/react-client/package.json +6 -0
  361. package/react-m/package.json +6 -0
  362. package/rollup.config.mjs +184 -0
  363. package/src/index.ts +1 -0
  364. package/src/react-client.ts +3 -0
  365. package/src/react-m.ts +3 -0
  366. package/src/react.ts +3 -0
  367. package/tsconfig.json +25 -0
  368. package/types/index.d.ts +1 -4
  369. package/types/react-client.d.ts +1 -0
  370. package/types/react-m.d.ts +1 -0
  371. package/types/react.d.ts +1 -0
  372. package/CHANGELOG.md +0 -378
  373. package/dist/animate.cjs.js +0 -22
  374. package/dist/animate.es.js +0 -19
  375. package/dist/main.cjs.js +0 -21
  376. package/dist/main.es.js +0 -3
  377. package/dist/motion.min.js +0 -1
  378. package/dist/motion.umd.js +0 -2364
  379. package/dist/size-index.js +0 -1
  380. package/lib/animate.js +0 -17
  381. package/lib/animate.js.map +0 -1
  382. package/types/animate.d.ts +0 -6
  383. package/types/animate.d.ts.map +0 -1
  384. package/types/index.d.ts.map +0 -1
@@ -0,0 +1,1583 @@
1
+ import { SubscriptionManager } from '../../utils/subscription-manager.mjs';
2
+ import { mixValues } from '../animation/mix-values.mjs';
3
+ import { copyBoxInto, copyAxisDeltaInto } from '../geometry/copy.mjs';
4
+ import { translateAxis, transformBox, applyBoxDelta, applyTreeDeltas } from '../geometry/delta-apply.mjs';
5
+ import { calcRelativePosition, calcRelativeBox, calcBoxDelta, calcLength, isNear } from '../geometry/delta-calc.mjs';
6
+ import { removeBoxTransforms } from '../geometry/delta-remove.mjs';
7
+ import { getValueTransition } from '../../animation/utils/get-value-transition.mjs';
8
+ import { boxEqualsRounded, isDeltaZero, axisDeltaEquals, aspectRatio, boxEquals } from '../geometry/utils.mjs';
9
+ import { NodeStack } from '../shared/stack.mjs';
10
+ import { scaleCorrectors } from '../styles/scale-correction.mjs';
11
+ import { buildProjectionTransform } from '../styles/transform.mjs';
12
+ import { eachAxis } from '../utils/each-axis.mjs';
13
+ import { hasTransform, hasScale, has2DTranslate } from '../utils/has-transform.mjs';
14
+ import { FlatTree } from '../../render/utils/flat-tree.mjs';
15
+ import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
16
+ import { globalProjectionState } from './state.mjs';
17
+ import { delay } from '../../utils/delay.mjs';
18
+ import { mixNumber } from '../../utils/mix/number.mjs';
19
+ import { isSVGElement } from '../../render/dom/utils/is-svg-element.mjs';
20
+ import { animateSingleValue } from '../../animation/animate/single-value.mjs';
21
+ import { clamp } from '../../utils/clamp.mjs';
22
+ import { cancelFrame, frameData, frameSteps, frame } from '../../frameloop/frame.mjs';
23
+ import { noop } from '../../utils/noop.mjs';
24
+ import { time } from '../../frameloop/sync-time.mjs';
25
+ import { microtask } from '../../frameloop/microtask.mjs';
26
+ import { getOptimisedAppearId } from '../../animation/optimized-appear/get-appear-id.mjs';
27
+ import { createBox, createDelta } from '../geometry/models.mjs';
28
+
29
+ const metrics = {
30
+ type: "projectionFrame",
31
+ totalNodes: 0,
32
+ resolvedTargetDeltas: 0,
33
+ recalculatedProjection: 0,
34
+ };
35
+ const isDebug = typeof window !== "undefined" && window.MotionDebug !== undefined;
36
+ const transformAxes = ["", "X", "Y", "Z"];
37
+ const hiddenVisibility = { visibility: "hidden" };
38
+ /**
39
+ * We use 1000 as the animation target as 0-1000 maps better to pixels than 0-1
40
+ * which has a noticeable difference in spring animations
41
+ */
42
+ const animationTarget = 1000;
43
+ let id = 0;
44
+ function resetDistortingTransform(key, visualElement, values, sharedAnimationValues) {
45
+ const { latestValues } = visualElement;
46
+ // Record the distorting transform and then temporarily set it to 0
47
+ if (latestValues[key]) {
48
+ values[key] = latestValues[key];
49
+ visualElement.setStaticValue(key, 0);
50
+ if (sharedAnimationValues) {
51
+ sharedAnimationValues[key] = 0;
52
+ }
53
+ }
54
+ }
55
+ function cancelTreeOptimisedTransformAnimations(projectionNode) {
56
+ projectionNode.hasCheckedOptimisedAppear = true;
57
+ if (projectionNode.root === projectionNode)
58
+ return;
59
+ const { visualElement } = projectionNode.options;
60
+ if (!visualElement)
61
+ return;
62
+ const appearId = getOptimisedAppearId(visualElement);
63
+ if (window.MotionHasOptimisedAnimation(appearId, "transform")) {
64
+ const { layout, layoutId } = projectionNode.options;
65
+ window.MotionCancelOptimisedAnimation(appearId, "transform", frame, !(layout || layoutId));
66
+ }
67
+ const { parent } = projectionNode;
68
+ if (parent && !parent.hasCheckedOptimisedAppear) {
69
+ cancelTreeOptimisedTransformAnimations(parent);
70
+ }
71
+ }
72
+ function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
73
+ return class ProjectionNode {
74
+ constructor(latestValues = {}, parent = defaultParent === null || defaultParent === void 0 ? void 0 : defaultParent()) {
75
+ /**
76
+ * A unique ID generated for every projection node.
77
+ */
78
+ this.id = id++;
79
+ /**
80
+ * An id that represents a unique session instigated by startUpdate.
81
+ */
82
+ this.animationId = 0;
83
+ /**
84
+ * A Set containing all this component's children. This is used to iterate
85
+ * through the children.
86
+ *
87
+ * TODO: This could be faster to iterate as a flat array stored on the root node.
88
+ */
89
+ this.children = new Set();
90
+ /**
91
+ * Options for the node. We use this to configure what kind of layout animations
92
+ * we should perform (if any).
93
+ */
94
+ this.options = {};
95
+ /**
96
+ * We use this to detect when its safe to shut down part of a projection tree.
97
+ * We have to keep projecting children for scale correction and relative projection
98
+ * until all their parents stop performing layout animations.
99
+ */
100
+ this.isTreeAnimating = false;
101
+ this.isAnimationBlocked = false;
102
+ /**
103
+ * Flag to true if we think this layout has been changed. We can't always know this,
104
+ * currently we set it to true every time a component renders, or if it has a layoutDependency
105
+ * if that has changed between renders. Additionally, components can be grouped by LayoutGroup
106
+ * and if one node is dirtied, they all are.
107
+ */
108
+ this.isLayoutDirty = false;
109
+ /**
110
+ * Flag to true if we think the projection calculations for this node needs
111
+ * recalculating as a result of an updated transform or layout animation.
112
+ */
113
+ this.isProjectionDirty = false;
114
+ /**
115
+ * Flag to true if the layout *or* transform has changed. This then gets propagated
116
+ * throughout the projection tree, forcing any element below to recalculate on the next frame.
117
+ */
118
+ this.isSharedProjectionDirty = false;
119
+ /**
120
+ * Flag transform dirty. This gets propagated throughout the whole tree but is only
121
+ * respected by shared nodes.
122
+ */
123
+ this.isTransformDirty = false;
124
+ /**
125
+ * Block layout updates for instant layout transitions throughout the tree.
126
+ */
127
+ this.updateManuallyBlocked = false;
128
+ this.updateBlockedByResize = false;
129
+ /**
130
+ * Set to true between the start of the first `willUpdate` call and the end of the `didUpdate`
131
+ * call.
132
+ */
133
+ this.isUpdating = false;
134
+ /**
135
+ * If this is an SVG element we currently disable projection transforms
136
+ */
137
+ this.isSVG = false;
138
+ /**
139
+ * Flag to true (during promotion) if a node doing an instant layout transition needs to reset
140
+ * its projection styles.
141
+ */
142
+ this.needsReset = false;
143
+ /**
144
+ * Flags whether this node should have its transform reset prior to measuring.
145
+ */
146
+ this.shouldResetTransform = false;
147
+ /**
148
+ * Store whether this node has been checked for optimised appear animations. As
149
+ * effects fire bottom-up, and we want to look up the tree for appear animations,
150
+ * this makes sure we only check each path once, stopping at nodes that
151
+ * have already been checked.
152
+ */
153
+ this.hasCheckedOptimisedAppear = false;
154
+ /**
155
+ * An object representing the calculated contextual/accumulated/tree scale.
156
+ * This will be used to scale calculcated projection transforms, as these are
157
+ * calculated in screen-space but need to be scaled for elements to layoutly
158
+ * make it to their calculated destinations.
159
+ *
160
+ * TODO: Lazy-init
161
+ */
162
+ this.treeScale = { x: 1, y: 1 };
163
+ /**
164
+ *
165
+ */
166
+ this.eventHandlers = new Map();
167
+ this.hasTreeAnimated = false;
168
+ // Note: Currently only running on root node
169
+ this.updateScheduled = false;
170
+ this.scheduleUpdate = () => this.update();
171
+ this.projectionUpdateScheduled = false;
172
+ this.checkUpdateFailed = () => {
173
+ if (this.isUpdating) {
174
+ this.isUpdating = false;
175
+ this.clearAllSnapshots();
176
+ }
177
+ };
178
+ /**
179
+ * This is a multi-step process as shared nodes might be of different depths. Nodes
180
+ * are sorted by depth order, so we need to resolve the entire tree before moving to
181
+ * the next step.
182
+ */
183
+ this.updateProjection = () => {
184
+ this.projectionUpdateScheduled = false;
185
+ /**
186
+ * Reset debug counts. Manually resetting rather than creating a new
187
+ * object each frame.
188
+ */
189
+ if (isDebug) {
190
+ metrics.totalNodes =
191
+ metrics.resolvedTargetDeltas =
192
+ metrics.recalculatedProjection =
193
+ 0;
194
+ }
195
+ this.nodes.forEach(propagateDirtyNodes);
196
+ this.nodes.forEach(resolveTargetDelta);
197
+ this.nodes.forEach(calcProjection);
198
+ this.nodes.forEach(cleanDirtyNodes);
199
+ if (isDebug) {
200
+ window.MotionDebug.record(metrics);
201
+ }
202
+ };
203
+ /**
204
+ * Frame calculations
205
+ */
206
+ this.resolvedRelativeTargetAt = 0.0;
207
+ this.hasProjected = false;
208
+ this.isVisible = true;
209
+ this.animationProgress = 0;
210
+ /**
211
+ * Shared layout
212
+ */
213
+ // TODO Only running on root node
214
+ this.sharedNodes = new Map();
215
+ this.latestValues = latestValues;
216
+ this.root = parent ? parent.root || parent : this;
217
+ this.path = parent ? [...parent.path, parent] : [];
218
+ this.parent = parent;
219
+ this.depth = parent ? parent.depth + 1 : 0;
220
+ for (let i = 0; i < this.path.length; i++) {
221
+ this.path[i].shouldResetTransform = true;
222
+ }
223
+ if (this.root === this)
224
+ this.nodes = new FlatTree();
225
+ }
226
+ addEventListener(name, handler) {
227
+ if (!this.eventHandlers.has(name)) {
228
+ this.eventHandlers.set(name, new SubscriptionManager());
229
+ }
230
+ return this.eventHandlers.get(name).add(handler);
231
+ }
232
+ notifyListeners(name, ...args) {
233
+ const subscriptionManager = this.eventHandlers.get(name);
234
+ subscriptionManager && subscriptionManager.notify(...args);
235
+ }
236
+ hasListeners(name) {
237
+ return this.eventHandlers.has(name);
238
+ }
239
+ /**
240
+ * Lifecycles
241
+ */
242
+ mount(instance, isLayoutDirty = this.root.hasTreeAnimated) {
243
+ if (this.instance)
244
+ return;
245
+ this.isSVG = isSVGElement(instance);
246
+ this.instance = instance;
247
+ const { layoutId, layout, visualElement } = this.options;
248
+ if (visualElement && !visualElement.current) {
249
+ visualElement.mount(instance);
250
+ }
251
+ this.root.nodes.add(this);
252
+ this.parent && this.parent.children.add(this);
253
+ if (isLayoutDirty && (layout || layoutId)) {
254
+ this.isLayoutDirty = true;
255
+ }
256
+ if (attachResizeListener) {
257
+ let cancelDelay;
258
+ const resizeUnblockUpdate = () => (this.root.updateBlockedByResize = false);
259
+ attachResizeListener(instance, () => {
260
+ this.root.updateBlockedByResize = true;
261
+ cancelDelay && cancelDelay();
262
+ cancelDelay = delay(resizeUnblockUpdate, 250);
263
+ if (globalProjectionState.hasAnimatedSinceResize) {
264
+ globalProjectionState.hasAnimatedSinceResize = false;
265
+ this.nodes.forEach(finishAnimation);
266
+ }
267
+ });
268
+ }
269
+ if (layoutId) {
270
+ this.root.registerSharedNode(layoutId, this);
271
+ }
272
+ // Only register the handler if it requires layout animation
273
+ if (this.options.animate !== false &&
274
+ visualElement &&
275
+ (layoutId || layout)) {
276
+ this.addEventListener("didUpdate", ({ delta, hasLayoutChanged, hasRelativeTargetChanged, layout: newLayout, }) => {
277
+ if (this.isTreeAnimationBlocked()) {
278
+ this.target = undefined;
279
+ this.relativeTarget = undefined;
280
+ return;
281
+ }
282
+ // TODO: Check here if an animation exists
283
+ const layoutTransition = this.options.transition ||
284
+ visualElement.getDefaultTransition() ||
285
+ defaultLayoutTransition;
286
+ const { onLayoutAnimationStart, onLayoutAnimationComplete, } = visualElement.getProps();
287
+ /**
288
+ * The target layout of the element might stay the same,
289
+ * but its position relative to its parent has changed.
290
+ */
291
+ const targetChanged = !this.targetLayout ||
292
+ !boxEqualsRounded(this.targetLayout, newLayout) ||
293
+ hasRelativeTargetChanged;
294
+ /**
295
+ * If the layout hasn't seemed to have changed, it might be that the
296
+ * element is visually in the same place in the document but its position
297
+ * relative to its parent has indeed changed. So here we check for that.
298
+ */
299
+ const hasOnlyRelativeTargetChanged = !hasLayoutChanged && hasRelativeTargetChanged;
300
+ if (this.options.layoutRoot ||
301
+ (this.resumeFrom && this.resumeFrom.instance) ||
302
+ hasOnlyRelativeTargetChanged ||
303
+ (hasLayoutChanged &&
304
+ (targetChanged || !this.currentAnimation))) {
305
+ if (this.resumeFrom) {
306
+ this.resumingFrom = this.resumeFrom;
307
+ this.resumingFrom.resumingFrom = undefined;
308
+ }
309
+ this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged);
310
+ const animationOptions = {
311
+ ...getValueTransition(layoutTransition, "layout"),
312
+ onPlay: onLayoutAnimationStart,
313
+ onComplete: onLayoutAnimationComplete,
314
+ };
315
+ if (visualElement.shouldReduceMotion ||
316
+ this.options.layoutRoot) {
317
+ animationOptions.delay = 0;
318
+ animationOptions.type = false;
319
+ }
320
+ this.startAnimation(animationOptions);
321
+ }
322
+ else {
323
+ /**
324
+ * If the layout hasn't changed and we have an animation that hasn't started yet,
325
+ * finish it immediately. Otherwise it will be animating from a location
326
+ * that was probably never commited to screen and look like a jumpy box.
327
+ */
328
+ if (!hasLayoutChanged) {
329
+ finishAnimation(this);
330
+ }
331
+ if (this.isLead() && this.options.onExitComplete) {
332
+ this.options.onExitComplete();
333
+ }
334
+ }
335
+ this.targetLayout = newLayout;
336
+ });
337
+ }
338
+ }
339
+ unmount() {
340
+ this.options.layoutId && this.willUpdate();
341
+ this.root.nodes.remove(this);
342
+ const stack = this.getStack();
343
+ stack && stack.remove(this);
344
+ this.parent && this.parent.children.delete(this);
345
+ this.instance = undefined;
346
+ cancelFrame(this.updateProjection);
347
+ }
348
+ // only on the root
349
+ blockUpdate() {
350
+ this.updateManuallyBlocked = true;
351
+ }
352
+ unblockUpdate() {
353
+ this.updateManuallyBlocked = false;
354
+ }
355
+ isUpdateBlocked() {
356
+ return this.updateManuallyBlocked || this.updateBlockedByResize;
357
+ }
358
+ isTreeAnimationBlocked() {
359
+ return (this.isAnimationBlocked ||
360
+ (this.parent && this.parent.isTreeAnimationBlocked()) ||
361
+ false);
362
+ }
363
+ // Note: currently only running on root node
364
+ startUpdate() {
365
+ if (this.isUpdateBlocked())
366
+ return;
367
+ this.isUpdating = true;
368
+ this.nodes && this.nodes.forEach(resetSkewAndRotation);
369
+ this.animationId++;
370
+ }
371
+ getTransformTemplate() {
372
+ const { visualElement } = this.options;
373
+ return visualElement && visualElement.getProps().transformTemplate;
374
+ }
375
+ willUpdate(shouldNotifyListeners = true) {
376
+ this.root.hasTreeAnimated = true;
377
+ if (this.root.isUpdateBlocked()) {
378
+ this.options.onExitComplete && this.options.onExitComplete();
379
+ return;
380
+ }
381
+ /**
382
+ * If we're running optimised appear animations then these must be
383
+ * cancelled before measuring the DOM. This is so we can measure
384
+ * the true layout of the element rather than the WAAPI animation
385
+ * which will be unaffected by the resetSkewAndRotate step.
386
+ *
387
+ * Note: This is a DOM write. Worst case scenario is this is sandwiched
388
+ * between other snapshot reads which will cause unnecessary style recalculations.
389
+ * This has to happen here though, as we don't yet know which nodes will need
390
+ * snapshots in startUpdate(), but we only want to cancel optimised animations
391
+ * if a layout animation measurement is actually going to be affected by them.
392
+ */
393
+ if (window.MotionCancelOptimisedAnimation &&
394
+ !this.hasCheckedOptimisedAppear) {
395
+ cancelTreeOptimisedTransformAnimations(this);
396
+ }
397
+ !this.root.isUpdating && this.root.startUpdate();
398
+ if (this.isLayoutDirty)
399
+ return;
400
+ this.isLayoutDirty = true;
401
+ for (let i = 0; i < this.path.length; i++) {
402
+ const node = this.path[i];
403
+ node.shouldResetTransform = true;
404
+ node.updateScroll("snapshot");
405
+ if (node.options.layoutRoot) {
406
+ node.willUpdate(false);
407
+ }
408
+ }
409
+ const { layoutId, layout } = this.options;
410
+ if (layoutId === undefined && !layout)
411
+ return;
412
+ const transformTemplate = this.getTransformTemplate();
413
+ this.prevTransformTemplateValue = transformTemplate
414
+ ? transformTemplate(this.latestValues, "")
415
+ : undefined;
416
+ this.updateSnapshot();
417
+ shouldNotifyListeners && this.notifyListeners("willUpdate");
418
+ }
419
+ update() {
420
+ this.updateScheduled = false;
421
+ const updateWasBlocked = this.isUpdateBlocked();
422
+ // When doing an instant transition, we skip the layout update,
423
+ // but should still clean up the measurements so that the next
424
+ // snapshot could be taken correctly.
425
+ if (updateWasBlocked) {
426
+ this.unblockUpdate();
427
+ this.clearAllSnapshots();
428
+ this.nodes.forEach(clearMeasurements);
429
+ return;
430
+ }
431
+ if (!this.isUpdating) {
432
+ this.nodes.forEach(clearIsLayoutDirty);
433
+ }
434
+ this.isUpdating = false;
435
+ /**
436
+ * Write
437
+ */
438
+ this.nodes.forEach(resetTransformStyle);
439
+ /**
440
+ * Read ==================
441
+ */
442
+ // Update layout measurements of updated children
443
+ this.nodes.forEach(updateLayout);
444
+ /**
445
+ * Write
446
+ */
447
+ // Notify listeners that the layout is updated
448
+ this.nodes.forEach(notifyLayoutUpdate);
449
+ this.clearAllSnapshots();
450
+ /**
451
+ * Manually flush any pending updates. Ideally
452
+ * we could leave this to the following requestAnimationFrame but this seems
453
+ * to leave a flash of incorrectly styled content.
454
+ */
455
+ const now = time.now();
456
+ frameData.delta = clamp(0, 1000 / 60, now - frameData.timestamp);
457
+ frameData.timestamp = now;
458
+ frameData.isProcessing = true;
459
+ frameSteps.update.process(frameData);
460
+ frameSteps.preRender.process(frameData);
461
+ frameSteps.render.process(frameData);
462
+ frameData.isProcessing = false;
463
+ }
464
+ didUpdate() {
465
+ if (!this.updateScheduled) {
466
+ this.updateScheduled = true;
467
+ microtask.read(this.scheduleUpdate);
468
+ }
469
+ }
470
+ clearAllSnapshots() {
471
+ this.nodes.forEach(clearSnapshot);
472
+ this.sharedNodes.forEach(removeLeadSnapshots);
473
+ }
474
+ scheduleUpdateProjection() {
475
+ if (!this.projectionUpdateScheduled) {
476
+ this.projectionUpdateScheduled = true;
477
+ frame.preRender(this.updateProjection, false, true);
478
+ }
479
+ }
480
+ scheduleCheckAfterUnmount() {
481
+ /**
482
+ * If the unmounting node is in a layoutGroup and did trigger a willUpdate,
483
+ * we manually call didUpdate to give a chance to the siblings to animate.
484
+ * Otherwise, cleanup all snapshots to prevents future nodes from reusing them.
485
+ */
486
+ frame.postRender(() => {
487
+ if (this.isLayoutDirty) {
488
+ this.root.didUpdate();
489
+ }
490
+ else {
491
+ this.root.checkUpdateFailed();
492
+ }
493
+ });
494
+ }
495
+ /**
496
+ * Update measurements
497
+ */
498
+ updateSnapshot() {
499
+ if (this.snapshot || !this.instance)
500
+ return;
501
+ this.snapshot = this.measure();
502
+ }
503
+ updateLayout() {
504
+ if (!this.instance)
505
+ return;
506
+ // TODO: Incorporate into a forwarded scroll offset
507
+ this.updateScroll();
508
+ if (!(this.options.alwaysMeasureLayout && this.isLead()) &&
509
+ !this.isLayoutDirty) {
510
+ return;
511
+ }
512
+ /**
513
+ * When a node is mounted, it simply resumes from the prevLead's
514
+ * snapshot instead of taking a new one, but the ancestors scroll
515
+ * might have updated while the prevLead is unmounted. We need to
516
+ * update the scroll again to make sure the layout we measure is
517
+ * up to date.
518
+ */
519
+ if (this.resumeFrom && !this.resumeFrom.instance) {
520
+ for (let i = 0; i < this.path.length; i++) {
521
+ const node = this.path[i];
522
+ node.updateScroll();
523
+ }
524
+ }
525
+ const prevLayout = this.layout;
526
+ this.layout = this.measure(false);
527
+ this.layoutCorrected = createBox();
528
+ this.isLayoutDirty = false;
529
+ this.projectionDelta = undefined;
530
+ this.notifyListeners("measure", this.layout.layoutBox);
531
+ const { visualElement } = this.options;
532
+ visualElement &&
533
+ visualElement.notify("LayoutMeasure", this.layout.layoutBox, prevLayout ? prevLayout.layoutBox : undefined);
534
+ }
535
+ updateScroll(phase = "measure") {
536
+ let needsMeasurement = Boolean(this.options.layoutScroll && this.instance);
537
+ if (this.scroll &&
538
+ this.scroll.animationId === this.root.animationId &&
539
+ this.scroll.phase === phase) {
540
+ needsMeasurement = false;
541
+ }
542
+ if (needsMeasurement) {
543
+ const isRoot = checkIsScrollRoot(this.instance);
544
+ this.scroll = {
545
+ animationId: this.root.animationId,
546
+ phase,
547
+ isRoot,
548
+ offset: measureScroll(this.instance),
549
+ wasRoot: this.scroll ? this.scroll.isRoot : isRoot,
550
+ };
551
+ }
552
+ }
553
+ resetTransform() {
554
+ if (!resetTransform)
555
+ return;
556
+ const isResetRequested = this.isLayoutDirty ||
557
+ this.shouldResetTransform ||
558
+ this.options.alwaysMeasureLayout;
559
+ const hasProjection = this.projectionDelta && !isDeltaZero(this.projectionDelta);
560
+ const transformTemplate = this.getTransformTemplate();
561
+ const transformTemplateValue = transformTemplate
562
+ ? transformTemplate(this.latestValues, "")
563
+ : undefined;
564
+ const transformTemplateHasChanged = transformTemplateValue !== this.prevTransformTemplateValue;
565
+ if (isResetRequested &&
566
+ (hasProjection ||
567
+ hasTransform(this.latestValues) ||
568
+ transformTemplateHasChanged)) {
569
+ resetTransform(this.instance, transformTemplateValue);
570
+ this.shouldResetTransform = false;
571
+ this.scheduleRender();
572
+ }
573
+ }
574
+ measure(removeTransform = true) {
575
+ const pageBox = this.measurePageBox();
576
+ let layoutBox = this.removeElementScroll(pageBox);
577
+ /**
578
+ * Measurements taken during the pre-render stage
579
+ * still have transforms applied so we remove them
580
+ * via calculation.
581
+ */
582
+ if (removeTransform) {
583
+ layoutBox = this.removeTransform(layoutBox);
584
+ }
585
+ roundBox(layoutBox);
586
+ return {
587
+ animationId: this.root.animationId,
588
+ measuredBox: pageBox,
589
+ layoutBox,
590
+ latestValues: {},
591
+ source: this.id,
592
+ };
593
+ }
594
+ measurePageBox() {
595
+ var _a;
596
+ const { visualElement } = this.options;
597
+ if (!visualElement)
598
+ return createBox();
599
+ const box = visualElement.measureViewportBox();
600
+ const wasInScrollRoot = ((_a = this.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot) || this.path.some(checkNodeWasScrollRoot);
601
+ if (!wasInScrollRoot) {
602
+ // Remove viewport scroll to give page-relative coordinates
603
+ const { scroll } = this.root;
604
+ if (scroll) {
605
+ translateAxis(box.x, scroll.offset.x);
606
+ translateAxis(box.y, scroll.offset.y);
607
+ }
608
+ }
609
+ return box;
610
+ }
611
+ removeElementScroll(box) {
612
+ var _a;
613
+ const boxWithoutScroll = createBox();
614
+ copyBoxInto(boxWithoutScroll, box);
615
+ if ((_a = this.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot) {
616
+ return boxWithoutScroll;
617
+ }
618
+ /**
619
+ * Performance TODO: Keep a cumulative scroll offset down the tree
620
+ * rather than loop back up the path.
621
+ */
622
+ for (let i = 0; i < this.path.length; i++) {
623
+ const node = this.path[i];
624
+ const { scroll, options } = node;
625
+ if (node !== this.root && scroll && options.layoutScroll) {
626
+ /**
627
+ * If this is a new scroll root, we want to remove all previous scrolls
628
+ * from the viewport box.
629
+ */
630
+ if (scroll.wasRoot) {
631
+ copyBoxInto(boxWithoutScroll, box);
632
+ }
633
+ translateAxis(boxWithoutScroll.x, scroll.offset.x);
634
+ translateAxis(boxWithoutScroll.y, scroll.offset.y);
635
+ }
636
+ }
637
+ return boxWithoutScroll;
638
+ }
639
+ applyTransform(box, transformOnly = false) {
640
+ const withTransforms = createBox();
641
+ copyBoxInto(withTransforms, box);
642
+ for (let i = 0; i < this.path.length; i++) {
643
+ const node = this.path[i];
644
+ if (!transformOnly &&
645
+ node.options.layoutScroll &&
646
+ node.scroll &&
647
+ node !== node.root) {
648
+ transformBox(withTransforms, {
649
+ x: -node.scroll.offset.x,
650
+ y: -node.scroll.offset.y,
651
+ });
652
+ }
653
+ if (!hasTransform(node.latestValues))
654
+ continue;
655
+ transformBox(withTransforms, node.latestValues);
656
+ }
657
+ if (hasTransform(this.latestValues)) {
658
+ transformBox(withTransforms, this.latestValues);
659
+ }
660
+ return withTransforms;
661
+ }
662
+ removeTransform(box) {
663
+ const boxWithoutTransform = createBox();
664
+ copyBoxInto(boxWithoutTransform, box);
665
+ for (let i = 0; i < this.path.length; i++) {
666
+ const node = this.path[i];
667
+ if (!node.instance)
668
+ continue;
669
+ if (!hasTransform(node.latestValues))
670
+ continue;
671
+ hasScale(node.latestValues) && node.updateSnapshot();
672
+ const sourceBox = createBox();
673
+ const nodeBox = node.measurePageBox();
674
+ copyBoxInto(sourceBox, nodeBox);
675
+ removeBoxTransforms(boxWithoutTransform, node.latestValues, node.snapshot ? node.snapshot.layoutBox : undefined, sourceBox);
676
+ }
677
+ if (hasTransform(this.latestValues)) {
678
+ removeBoxTransforms(boxWithoutTransform, this.latestValues);
679
+ }
680
+ return boxWithoutTransform;
681
+ }
682
+ setTargetDelta(delta) {
683
+ this.targetDelta = delta;
684
+ this.root.scheduleUpdateProjection();
685
+ this.isProjectionDirty = true;
686
+ }
687
+ setOptions(options) {
688
+ this.options = {
689
+ ...this.options,
690
+ ...options,
691
+ crossfade: options.crossfade !== undefined ? options.crossfade : true,
692
+ };
693
+ }
694
+ clearMeasurements() {
695
+ this.scroll = undefined;
696
+ this.layout = undefined;
697
+ this.snapshot = undefined;
698
+ this.prevTransformTemplateValue = undefined;
699
+ this.targetDelta = undefined;
700
+ this.target = undefined;
701
+ this.isLayoutDirty = false;
702
+ }
703
+ forceRelativeParentToResolveTarget() {
704
+ if (!this.relativeParent)
705
+ return;
706
+ /**
707
+ * If the parent target isn't up-to-date, force it to update.
708
+ * This is an unfortunate de-optimisation as it means any updating relative
709
+ * projection will cause all the relative parents to recalculate back
710
+ * up the tree.
711
+ */
712
+ if (this.relativeParent.resolvedRelativeTargetAt !==
713
+ frameData.timestamp) {
714
+ this.relativeParent.resolveTargetDelta(true);
715
+ }
716
+ }
717
+ resolveTargetDelta(forceRecalculation = false) {
718
+ var _a;
719
+ /**
720
+ * Once the dirty status of nodes has been spread through the tree, we also
721
+ * need to check if we have a shared node of a different depth that has itself
722
+ * been dirtied.
723
+ */
724
+ const lead = this.getLead();
725
+ this.isProjectionDirty || (this.isProjectionDirty = lead.isProjectionDirty);
726
+ this.isTransformDirty || (this.isTransformDirty = lead.isTransformDirty);
727
+ this.isSharedProjectionDirty || (this.isSharedProjectionDirty = lead.isSharedProjectionDirty);
728
+ const isShared = Boolean(this.resumingFrom) || this !== lead;
729
+ /**
730
+ * We don't use transform for this step of processing so we don't
731
+ * need to check whether any nodes have changed transform.
732
+ */
733
+ const canSkip = !(forceRecalculation ||
734
+ (isShared && this.isSharedProjectionDirty) ||
735
+ this.isProjectionDirty ||
736
+ ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isProjectionDirty) ||
737
+ this.attemptToResolveRelativeTarget ||
738
+ this.root.updateBlockedByResize);
739
+ if (canSkip)
740
+ return;
741
+ const { layout, layoutId } = this.options;
742
+ /**
743
+ * If we have no layout, we can't perform projection, so early return
744
+ */
745
+ if (!this.layout || !(layout || layoutId))
746
+ return;
747
+ this.resolvedRelativeTargetAt = frameData.timestamp;
748
+ /**
749
+ * If we don't have a targetDelta but do have a layout, we can attempt to resolve
750
+ * a relativeParent. This will allow a component to perform scale correction
751
+ * even if no animation has started.
752
+ */
753
+ if (!this.targetDelta && !this.relativeTarget) {
754
+ const relativeParent = this.getClosestProjectingParent();
755
+ if (relativeParent &&
756
+ relativeParent.layout &&
757
+ this.animationProgress !== 1) {
758
+ this.relativeParent = relativeParent;
759
+ this.forceRelativeParentToResolveTarget();
760
+ this.relativeTarget = createBox();
761
+ this.relativeTargetOrigin = createBox();
762
+ calcRelativePosition(this.relativeTargetOrigin, this.layout.layoutBox, relativeParent.layout.layoutBox);
763
+ copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
764
+ }
765
+ else {
766
+ this.relativeParent = this.relativeTarget = undefined;
767
+ }
768
+ }
769
+ /**
770
+ * If we have no relative target or no target delta our target isn't valid
771
+ * for this frame.
772
+ */
773
+ if (!this.relativeTarget && !this.targetDelta)
774
+ return;
775
+ /**
776
+ * Lazy-init target data structure
777
+ */
778
+ if (!this.target) {
779
+ this.target = createBox();
780
+ this.targetWithTransforms = createBox();
781
+ }
782
+ /**
783
+ * If we've got a relative box for this component, resolve it into a target relative to the parent.
784
+ */
785
+ if (this.relativeTarget &&
786
+ this.relativeTargetOrigin &&
787
+ this.relativeParent &&
788
+ this.relativeParent.target) {
789
+ this.forceRelativeParentToResolveTarget();
790
+ calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target);
791
+ /**
792
+ * If we've only got a targetDelta, resolve it into a target
793
+ */
794
+ }
795
+ else if (this.targetDelta) {
796
+ if (Boolean(this.resumingFrom)) {
797
+ // TODO: This is creating a new object every frame
798
+ this.target = this.applyTransform(this.layout.layoutBox);
799
+ }
800
+ else {
801
+ copyBoxInto(this.target, this.layout.layoutBox);
802
+ }
803
+ applyBoxDelta(this.target, this.targetDelta);
804
+ }
805
+ else {
806
+ /**
807
+ * If no target, use own layout as target
808
+ */
809
+ copyBoxInto(this.target, this.layout.layoutBox);
810
+ }
811
+ /**
812
+ * If we've been told to attempt to resolve a relative target, do so.
813
+ */
814
+ if (this.attemptToResolveRelativeTarget) {
815
+ this.attemptToResolveRelativeTarget = false;
816
+ const relativeParent = this.getClosestProjectingParent();
817
+ if (relativeParent &&
818
+ Boolean(relativeParent.resumingFrom) ===
819
+ Boolean(this.resumingFrom) &&
820
+ !relativeParent.options.layoutScroll &&
821
+ relativeParent.target &&
822
+ this.animationProgress !== 1) {
823
+ this.relativeParent = relativeParent;
824
+ this.forceRelativeParentToResolveTarget();
825
+ this.relativeTarget = createBox();
826
+ this.relativeTargetOrigin = createBox();
827
+ calcRelativePosition(this.relativeTargetOrigin, this.target, relativeParent.target);
828
+ copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
829
+ }
830
+ else {
831
+ this.relativeParent = this.relativeTarget = undefined;
832
+ }
833
+ }
834
+ /**
835
+ * Increase debug counter for resolved target deltas
836
+ */
837
+ if (isDebug) {
838
+ metrics.resolvedTargetDeltas++;
839
+ }
840
+ }
841
+ getClosestProjectingParent() {
842
+ if (!this.parent ||
843
+ hasScale(this.parent.latestValues) ||
844
+ has2DTranslate(this.parent.latestValues)) {
845
+ return undefined;
846
+ }
847
+ if (this.parent.isProjecting()) {
848
+ return this.parent;
849
+ }
850
+ else {
851
+ return this.parent.getClosestProjectingParent();
852
+ }
853
+ }
854
+ isProjecting() {
855
+ return Boolean((this.relativeTarget ||
856
+ this.targetDelta ||
857
+ this.options.layoutRoot) &&
858
+ this.layout);
859
+ }
860
+ calcProjection() {
861
+ var _a;
862
+ const lead = this.getLead();
863
+ const isShared = Boolean(this.resumingFrom) || this !== lead;
864
+ let canSkip = true;
865
+ /**
866
+ * If this is a normal layout animation and neither this node nor its nearest projecting
867
+ * is dirty then we can't skip.
868
+ */
869
+ if (this.isProjectionDirty || ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isProjectionDirty)) {
870
+ canSkip = false;
871
+ }
872
+ /**
873
+ * If this is a shared layout animation and this node's shared projection is dirty then
874
+ * we can't skip.
875
+ */
876
+ if (isShared &&
877
+ (this.isSharedProjectionDirty || this.isTransformDirty)) {
878
+ canSkip = false;
879
+ }
880
+ /**
881
+ * If we have resolved the target this frame we must recalculate the
882
+ * projection to ensure it visually represents the internal calculations.
883
+ */
884
+ if (this.resolvedRelativeTargetAt === frameData.timestamp) {
885
+ canSkip = false;
886
+ }
887
+ if (canSkip)
888
+ return;
889
+ const { layout, layoutId } = this.options;
890
+ /**
891
+ * If this section of the tree isn't animating we can
892
+ * delete our target sources for the following frame.
893
+ */
894
+ this.isTreeAnimating = Boolean((this.parent && this.parent.isTreeAnimating) ||
895
+ this.currentAnimation ||
896
+ this.pendingAnimation);
897
+ if (!this.isTreeAnimating) {
898
+ this.targetDelta = this.relativeTarget = undefined;
899
+ }
900
+ if (!this.layout || !(layout || layoutId))
901
+ return;
902
+ /**
903
+ * Reset the corrected box with the latest values from box, as we're then going
904
+ * to perform mutative operations on it.
905
+ */
906
+ copyBoxInto(this.layoutCorrected, this.layout.layoutBox);
907
+ /**
908
+ * Record previous tree scales before updating.
909
+ */
910
+ const prevTreeScaleX = this.treeScale.x;
911
+ const prevTreeScaleY = this.treeScale.y;
912
+ /**
913
+ * Apply all the parent deltas to this box to produce the corrected box. This
914
+ * is the layout box, as it will appear on screen as a result of the transforms of its parents.
915
+ */
916
+ applyTreeDeltas(this.layoutCorrected, this.treeScale, this.path, isShared);
917
+ /**
918
+ * If this layer needs to perform scale correction but doesn't have a target,
919
+ * use the layout as the target.
920
+ */
921
+ if (lead.layout &&
922
+ !lead.target &&
923
+ (this.treeScale.x !== 1 || this.treeScale.y !== 1)) {
924
+ lead.target = lead.layout.layoutBox;
925
+ lead.targetWithTransforms = createBox();
926
+ }
927
+ const { target } = lead;
928
+ if (!target) {
929
+ /**
930
+ * If we don't have a target to project into, but we were previously
931
+ * projecting, we want to remove the stored transform and schedule
932
+ * a render to ensure the elements reflect the removed transform.
933
+ */
934
+ if (this.prevProjectionDelta) {
935
+ this.createProjectionDeltas();
936
+ this.scheduleRender();
937
+ }
938
+ return;
939
+ }
940
+ if (!this.projectionDelta || !this.prevProjectionDelta) {
941
+ this.createProjectionDeltas();
942
+ }
943
+ else {
944
+ copyAxisDeltaInto(this.prevProjectionDelta.x, this.projectionDelta.x);
945
+ copyAxisDeltaInto(this.prevProjectionDelta.y, this.projectionDelta.y);
946
+ }
947
+ /**
948
+ * Update the delta between the corrected box and the target box before user-set transforms were applied.
949
+ * This will allow us to calculate the corrected borderRadius and boxShadow to compensate
950
+ * for our layout reprojection, but still allow them to be scaled correctly by the user.
951
+ * It might be that to simplify this we may want to accept that user-set scale is also corrected
952
+ * and we wouldn't have to keep and calc both deltas, OR we could support a user setting
953
+ * to allow people to choose whether these styles are corrected based on just the
954
+ * layout reprojection or the final bounding box.
955
+ */
956
+ calcBoxDelta(this.projectionDelta, this.layoutCorrected, target, this.latestValues);
957
+ if (this.treeScale.x !== prevTreeScaleX ||
958
+ this.treeScale.y !== prevTreeScaleY ||
959
+ !axisDeltaEquals(this.projectionDelta.x, this.prevProjectionDelta.x) ||
960
+ !axisDeltaEquals(this.projectionDelta.y, this.prevProjectionDelta.y)) {
961
+ this.hasProjected = true;
962
+ this.scheduleRender();
963
+ this.notifyListeners("projectionUpdate", target);
964
+ }
965
+ /**
966
+ * Increase debug counter for recalculated projections
967
+ */
968
+ if (isDebug) {
969
+ metrics.recalculatedProjection++;
970
+ }
971
+ }
972
+ hide() {
973
+ this.isVisible = false;
974
+ // TODO: Schedule render
975
+ }
976
+ show() {
977
+ this.isVisible = true;
978
+ // TODO: Schedule render
979
+ }
980
+ scheduleRender(notifyAll = true) {
981
+ var _a;
982
+ (_a = this.options.visualElement) === null || _a === void 0 ? void 0 : _a.scheduleRender();
983
+ if (notifyAll) {
984
+ const stack = this.getStack();
985
+ stack && stack.scheduleRender();
986
+ }
987
+ if (this.resumingFrom && !this.resumingFrom.instance) {
988
+ this.resumingFrom = undefined;
989
+ }
990
+ }
991
+ createProjectionDeltas() {
992
+ this.prevProjectionDelta = createDelta();
993
+ this.projectionDelta = createDelta();
994
+ this.projectionDeltaWithTransform = createDelta();
995
+ }
996
+ setAnimationOrigin(delta, hasOnlyRelativeTargetChanged = false) {
997
+ const snapshot = this.snapshot;
998
+ const snapshotLatestValues = snapshot
999
+ ? snapshot.latestValues
1000
+ : {};
1001
+ const mixedValues = { ...this.latestValues };
1002
+ const targetDelta = createDelta();
1003
+ if (!this.relativeParent ||
1004
+ !this.relativeParent.options.layoutRoot) {
1005
+ this.relativeTarget = this.relativeTargetOrigin = undefined;
1006
+ }
1007
+ this.attemptToResolveRelativeTarget = !hasOnlyRelativeTargetChanged;
1008
+ const relativeLayout = createBox();
1009
+ const snapshotSource = snapshot ? snapshot.source : undefined;
1010
+ const layoutSource = this.layout ? this.layout.source : undefined;
1011
+ const isSharedLayoutAnimation = snapshotSource !== layoutSource;
1012
+ const stack = this.getStack();
1013
+ const isOnlyMember = !stack || stack.members.length <= 1;
1014
+ const shouldCrossfadeOpacity = Boolean(isSharedLayoutAnimation &&
1015
+ !isOnlyMember &&
1016
+ this.options.crossfade === true &&
1017
+ !this.path.some(hasOpacityCrossfade));
1018
+ this.animationProgress = 0;
1019
+ let prevRelativeTarget;
1020
+ this.mixTargetDelta = (latest) => {
1021
+ const progress = latest / 1000;
1022
+ mixAxisDelta(targetDelta.x, delta.x, progress);
1023
+ mixAxisDelta(targetDelta.y, delta.y, progress);
1024
+ this.setTargetDelta(targetDelta);
1025
+ if (this.relativeTarget &&
1026
+ this.relativeTargetOrigin &&
1027
+ this.layout &&
1028
+ this.relativeParent &&
1029
+ this.relativeParent.layout) {
1030
+ calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
1031
+ mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
1032
+ /**
1033
+ * If this is an unchanged relative target we can consider the
1034
+ * projection not dirty.
1035
+ */
1036
+ if (prevRelativeTarget &&
1037
+ boxEquals(this.relativeTarget, prevRelativeTarget)) {
1038
+ this.isProjectionDirty = false;
1039
+ }
1040
+ if (!prevRelativeTarget)
1041
+ prevRelativeTarget = createBox();
1042
+ copyBoxInto(prevRelativeTarget, this.relativeTarget);
1043
+ }
1044
+ if (isSharedLayoutAnimation) {
1045
+ this.animationValues = mixedValues;
1046
+ mixValues(mixedValues, snapshotLatestValues, this.latestValues, progress, shouldCrossfadeOpacity, isOnlyMember);
1047
+ }
1048
+ this.root.scheduleUpdateProjection();
1049
+ this.scheduleRender();
1050
+ this.animationProgress = progress;
1051
+ };
1052
+ this.mixTargetDelta(this.options.layoutRoot ? 1000 : 0);
1053
+ }
1054
+ startAnimation(options) {
1055
+ this.notifyListeners("animationStart");
1056
+ this.currentAnimation && this.currentAnimation.stop();
1057
+ if (this.resumingFrom && this.resumingFrom.currentAnimation) {
1058
+ this.resumingFrom.currentAnimation.stop();
1059
+ }
1060
+ if (this.pendingAnimation) {
1061
+ cancelFrame(this.pendingAnimation);
1062
+ this.pendingAnimation = undefined;
1063
+ }
1064
+ /**
1065
+ * Start the animation in the next frame to have a frame with progress 0,
1066
+ * where the target is the same as when the animation started, so we can
1067
+ * calculate the relative positions correctly for instant transitions.
1068
+ */
1069
+ this.pendingAnimation = frame.update(() => {
1070
+ globalProjectionState.hasAnimatedSinceResize = true;
1071
+ this.currentAnimation = animateSingleValue(0, animationTarget, {
1072
+ ...options,
1073
+ onUpdate: (latest) => {
1074
+ this.mixTargetDelta(latest);
1075
+ options.onUpdate && options.onUpdate(latest);
1076
+ },
1077
+ onComplete: () => {
1078
+ options.onComplete && options.onComplete();
1079
+ this.completeAnimation();
1080
+ },
1081
+ });
1082
+ if (this.resumingFrom) {
1083
+ this.resumingFrom.currentAnimation = this.currentAnimation;
1084
+ }
1085
+ this.pendingAnimation = undefined;
1086
+ });
1087
+ }
1088
+ completeAnimation() {
1089
+ if (this.resumingFrom) {
1090
+ this.resumingFrom.currentAnimation = undefined;
1091
+ this.resumingFrom.preserveOpacity = undefined;
1092
+ }
1093
+ const stack = this.getStack();
1094
+ stack && stack.exitAnimationComplete();
1095
+ this.resumingFrom =
1096
+ this.currentAnimation =
1097
+ this.animationValues =
1098
+ undefined;
1099
+ this.notifyListeners("animationComplete");
1100
+ }
1101
+ finishAnimation() {
1102
+ if (this.currentAnimation) {
1103
+ this.mixTargetDelta && this.mixTargetDelta(animationTarget);
1104
+ this.currentAnimation.stop();
1105
+ }
1106
+ this.completeAnimation();
1107
+ }
1108
+ applyTransformsToTarget() {
1109
+ const lead = this.getLead();
1110
+ let { targetWithTransforms, target, layout, latestValues } = lead;
1111
+ if (!targetWithTransforms || !target || !layout)
1112
+ return;
1113
+ /**
1114
+ * If we're only animating position, and this element isn't the lead element,
1115
+ * then instead of projecting into the lead box we instead want to calculate
1116
+ * a new target that aligns the two boxes but maintains the layout shape.
1117
+ */
1118
+ if (this !== lead &&
1119
+ this.layout &&
1120
+ layout &&
1121
+ shouldAnimatePositionOnly(this.options.animationType, this.layout.layoutBox, layout.layoutBox)) {
1122
+ target = this.target || createBox();
1123
+ const xLength = calcLength(this.layout.layoutBox.x);
1124
+ target.x.min = lead.target.x.min;
1125
+ target.x.max = target.x.min + xLength;
1126
+ const yLength = calcLength(this.layout.layoutBox.y);
1127
+ target.y.min = lead.target.y.min;
1128
+ target.y.max = target.y.min + yLength;
1129
+ }
1130
+ copyBoxInto(targetWithTransforms, target);
1131
+ /**
1132
+ * Apply the latest user-set transforms to the targetBox to produce the targetBoxFinal.
1133
+ * This is the final box that we will then project into by calculating a transform delta and
1134
+ * applying it to the corrected box.
1135
+ */
1136
+ transformBox(targetWithTransforms, latestValues);
1137
+ /**
1138
+ * Update the delta between the corrected box and the final target box, after
1139
+ * user-set transforms are applied to it. This will be used by the renderer to
1140
+ * create a transform style that will reproject the element from its layout layout
1141
+ * into the desired bounding box.
1142
+ */
1143
+ calcBoxDelta(this.projectionDeltaWithTransform, this.layoutCorrected, targetWithTransforms, latestValues);
1144
+ }
1145
+ registerSharedNode(layoutId, node) {
1146
+ if (!this.sharedNodes.has(layoutId)) {
1147
+ this.sharedNodes.set(layoutId, new NodeStack());
1148
+ }
1149
+ const stack = this.sharedNodes.get(layoutId);
1150
+ stack.add(node);
1151
+ const config = node.options.initialPromotionConfig;
1152
+ node.promote({
1153
+ transition: config ? config.transition : undefined,
1154
+ preserveFollowOpacity: config && config.shouldPreserveFollowOpacity
1155
+ ? config.shouldPreserveFollowOpacity(node)
1156
+ : undefined,
1157
+ });
1158
+ }
1159
+ isLead() {
1160
+ const stack = this.getStack();
1161
+ return stack ? stack.lead === this : true;
1162
+ }
1163
+ getLead() {
1164
+ var _a;
1165
+ const { layoutId } = this.options;
1166
+ return layoutId ? ((_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.lead) || this : this;
1167
+ }
1168
+ getPrevLead() {
1169
+ var _a;
1170
+ const { layoutId } = this.options;
1171
+ return layoutId ? (_a = this.getStack()) === null || _a === void 0 ? void 0 : _a.prevLead : undefined;
1172
+ }
1173
+ getStack() {
1174
+ const { layoutId } = this.options;
1175
+ if (layoutId)
1176
+ return this.root.sharedNodes.get(layoutId);
1177
+ }
1178
+ promote({ needsReset, transition, preserveFollowOpacity, } = {}) {
1179
+ const stack = this.getStack();
1180
+ if (stack)
1181
+ stack.promote(this, preserveFollowOpacity);
1182
+ if (needsReset) {
1183
+ this.projectionDelta = undefined;
1184
+ this.needsReset = true;
1185
+ }
1186
+ if (transition)
1187
+ this.setOptions({ transition });
1188
+ }
1189
+ relegate() {
1190
+ const stack = this.getStack();
1191
+ if (stack) {
1192
+ return stack.relegate(this);
1193
+ }
1194
+ else {
1195
+ return false;
1196
+ }
1197
+ }
1198
+ resetSkewAndRotation() {
1199
+ const { visualElement } = this.options;
1200
+ if (!visualElement)
1201
+ return;
1202
+ // If there's no detected skew or rotation values, we can early return without a forced render.
1203
+ let hasDistortingTransform = false;
1204
+ /**
1205
+ * An unrolled check for rotation values. Most elements don't have any rotation and
1206
+ * skipping the nested loop and new object creation is 50% faster.
1207
+ */
1208
+ const { latestValues } = visualElement;
1209
+ if (latestValues.z ||
1210
+ latestValues.rotate ||
1211
+ latestValues.rotateX ||
1212
+ latestValues.rotateY ||
1213
+ latestValues.rotateZ ||
1214
+ latestValues.skewX ||
1215
+ latestValues.skewY) {
1216
+ hasDistortingTransform = true;
1217
+ }
1218
+ // If there's no distorting values, we don't need to do any more.
1219
+ if (!hasDistortingTransform)
1220
+ return;
1221
+ const resetValues = {};
1222
+ if (latestValues.z) {
1223
+ resetDistortingTransform("z", visualElement, resetValues, this.animationValues);
1224
+ }
1225
+ // Check the skew and rotate value of all axes and reset to 0
1226
+ for (let i = 0; i < transformAxes.length; i++) {
1227
+ resetDistortingTransform(`rotate${transformAxes[i]}`, visualElement, resetValues, this.animationValues);
1228
+ resetDistortingTransform(`skew${transformAxes[i]}`, visualElement, resetValues, this.animationValues);
1229
+ }
1230
+ // Force a render of this element to apply the transform with all skews and rotations
1231
+ // set to 0.
1232
+ visualElement.render();
1233
+ // Put back all the values we reset
1234
+ for (const key in resetValues) {
1235
+ visualElement.setStaticValue(key, resetValues[key]);
1236
+ if (this.animationValues) {
1237
+ this.animationValues[key] = resetValues[key];
1238
+ }
1239
+ }
1240
+ // Schedule a render for the next frame. This ensures we won't visually
1241
+ // see the element with the reset rotate value applied.
1242
+ visualElement.scheduleRender();
1243
+ }
1244
+ getProjectionStyles(styleProp) {
1245
+ var _a, _b;
1246
+ if (!this.instance || this.isSVG)
1247
+ return undefined;
1248
+ if (!this.isVisible) {
1249
+ return hiddenVisibility;
1250
+ }
1251
+ const styles = {
1252
+ visibility: "",
1253
+ };
1254
+ const transformTemplate = this.getTransformTemplate();
1255
+ if (this.needsReset) {
1256
+ this.needsReset = false;
1257
+ styles.opacity = "";
1258
+ styles.pointerEvents =
1259
+ resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || "";
1260
+ styles.transform = transformTemplate
1261
+ ? transformTemplate(this.latestValues, "")
1262
+ : "none";
1263
+ return styles;
1264
+ }
1265
+ const lead = this.getLead();
1266
+ if (!this.projectionDelta || !this.layout || !lead.target) {
1267
+ const emptyStyles = {};
1268
+ if (this.options.layoutId) {
1269
+ emptyStyles.opacity =
1270
+ this.latestValues.opacity !== undefined
1271
+ ? this.latestValues.opacity
1272
+ : 1;
1273
+ emptyStyles.pointerEvents =
1274
+ resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || "";
1275
+ }
1276
+ if (this.hasProjected && !hasTransform(this.latestValues)) {
1277
+ emptyStyles.transform = transformTemplate
1278
+ ? transformTemplate({}, "")
1279
+ : "none";
1280
+ this.hasProjected = false;
1281
+ }
1282
+ return emptyStyles;
1283
+ }
1284
+ const valuesToRender = lead.animationValues || lead.latestValues;
1285
+ this.applyTransformsToTarget();
1286
+ styles.transform = buildProjectionTransform(this.projectionDeltaWithTransform, this.treeScale, valuesToRender);
1287
+ if (transformTemplate) {
1288
+ styles.transform = transformTemplate(valuesToRender, styles.transform);
1289
+ }
1290
+ const { x, y } = this.projectionDelta;
1291
+ styles.transformOrigin = `${x.origin * 100}% ${y.origin * 100}% 0`;
1292
+ if (lead.animationValues) {
1293
+ /**
1294
+ * If the lead component is animating, assign this either the entering/leaving
1295
+ * opacity
1296
+ */
1297
+ styles.opacity =
1298
+ lead === this
1299
+ ? (_b = (_a = valuesToRender.opacity) !== null && _a !== void 0 ? _a : this.latestValues.opacity) !== null && _b !== void 0 ? _b : 1
1300
+ : this.preserveOpacity
1301
+ ? this.latestValues.opacity
1302
+ : valuesToRender.opacityExit;
1303
+ }
1304
+ else {
1305
+ /**
1306
+ * Or we're not animating at all, set the lead component to its layout
1307
+ * opacity and other components to hidden.
1308
+ */
1309
+ styles.opacity =
1310
+ lead === this
1311
+ ? valuesToRender.opacity !== undefined
1312
+ ? valuesToRender.opacity
1313
+ : ""
1314
+ : valuesToRender.opacityExit !== undefined
1315
+ ? valuesToRender.opacityExit
1316
+ : 0;
1317
+ }
1318
+ /**
1319
+ * Apply scale correction
1320
+ */
1321
+ for (const key in scaleCorrectors) {
1322
+ if (valuesToRender[key] === undefined)
1323
+ continue;
1324
+ const { correct, applyTo } = scaleCorrectors[key];
1325
+ /**
1326
+ * Only apply scale correction to the value if we have an
1327
+ * active projection transform. Otherwise these values become
1328
+ * vulnerable to distortion if the element changes size without
1329
+ * a corresponding layout animation.
1330
+ */
1331
+ const corrected = styles.transform === "none"
1332
+ ? valuesToRender[key]
1333
+ : correct(valuesToRender[key], lead);
1334
+ if (applyTo) {
1335
+ const num = applyTo.length;
1336
+ for (let i = 0; i < num; i++) {
1337
+ styles[applyTo[i]] = corrected;
1338
+ }
1339
+ }
1340
+ else {
1341
+ styles[key] = corrected;
1342
+ }
1343
+ }
1344
+ /**
1345
+ * Disable pointer events on follow components. This is to ensure
1346
+ * that if a follow component covers a lead component it doesn't block
1347
+ * pointer events on the lead.
1348
+ */
1349
+ if (this.options.layoutId) {
1350
+ styles.pointerEvents =
1351
+ lead === this
1352
+ ? resolveMotionValue(styleProp === null || styleProp === void 0 ? void 0 : styleProp.pointerEvents) || ""
1353
+ : "none";
1354
+ }
1355
+ return styles;
1356
+ }
1357
+ clearSnapshot() {
1358
+ this.resumeFrom = this.snapshot = undefined;
1359
+ }
1360
+ // Only run on root
1361
+ resetTree() {
1362
+ this.root.nodes.forEach((node) => { var _a; return (_a = node.currentAnimation) === null || _a === void 0 ? void 0 : _a.stop(); });
1363
+ this.root.nodes.forEach(clearMeasurements);
1364
+ this.root.sharedNodes.clear();
1365
+ }
1366
+ };
1367
+ }
1368
+ function updateLayout(node) {
1369
+ node.updateLayout();
1370
+ }
1371
+ function notifyLayoutUpdate(node) {
1372
+ var _a;
1373
+ const snapshot = ((_a = node.resumeFrom) === null || _a === void 0 ? void 0 : _a.snapshot) || node.snapshot;
1374
+ if (node.isLead() &&
1375
+ node.layout &&
1376
+ snapshot &&
1377
+ node.hasListeners("didUpdate")) {
1378
+ const { layoutBox: layout, measuredBox: measuredLayout } = node.layout;
1379
+ const { animationType } = node.options;
1380
+ const isShared = snapshot.source !== node.layout.source;
1381
+ // TODO Maybe we want to also resize the layout snapshot so we don't trigger
1382
+ // animations for instance if layout="size" and an element has only changed position
1383
+ if (animationType === "size") {
1384
+ eachAxis((axis) => {
1385
+ const axisSnapshot = isShared
1386
+ ? snapshot.measuredBox[axis]
1387
+ : snapshot.layoutBox[axis];
1388
+ const length = calcLength(axisSnapshot);
1389
+ axisSnapshot.min = layout[axis].min;
1390
+ axisSnapshot.max = axisSnapshot.min + length;
1391
+ });
1392
+ }
1393
+ else if (shouldAnimatePositionOnly(animationType, snapshot.layoutBox, layout)) {
1394
+ eachAxis((axis) => {
1395
+ const axisSnapshot = isShared
1396
+ ? snapshot.measuredBox[axis]
1397
+ : snapshot.layoutBox[axis];
1398
+ const length = calcLength(layout[axis]);
1399
+ axisSnapshot.max = axisSnapshot.min + length;
1400
+ /**
1401
+ * Ensure relative target gets resized and rerendererd
1402
+ */
1403
+ if (node.relativeTarget && !node.currentAnimation) {
1404
+ node.isProjectionDirty = true;
1405
+ node.relativeTarget[axis].max =
1406
+ node.relativeTarget[axis].min + length;
1407
+ }
1408
+ });
1409
+ }
1410
+ const layoutDelta = createDelta();
1411
+ calcBoxDelta(layoutDelta, layout, snapshot.layoutBox);
1412
+ const visualDelta = createDelta();
1413
+ if (isShared) {
1414
+ calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot.measuredBox);
1415
+ }
1416
+ else {
1417
+ calcBoxDelta(visualDelta, layout, snapshot.layoutBox);
1418
+ }
1419
+ const hasLayoutChanged = !isDeltaZero(layoutDelta);
1420
+ let hasRelativeTargetChanged = false;
1421
+ if (!node.resumeFrom) {
1422
+ const relativeParent = node.getClosestProjectingParent();
1423
+ /**
1424
+ * If the relativeParent is itself resuming from a different element then
1425
+ * the relative snapshot is not relavent
1426
+ */
1427
+ if (relativeParent && !relativeParent.resumeFrom) {
1428
+ const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
1429
+ if (parentSnapshot && parentLayout) {
1430
+ const relativeSnapshot = createBox();
1431
+ calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
1432
+ const relativeLayout = createBox();
1433
+ calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
1434
+ if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) {
1435
+ hasRelativeTargetChanged = true;
1436
+ }
1437
+ if (relativeParent.options.layoutRoot) {
1438
+ node.relativeTarget = relativeLayout;
1439
+ node.relativeTargetOrigin = relativeSnapshot;
1440
+ node.relativeParent = relativeParent;
1441
+ }
1442
+ }
1443
+ }
1444
+ }
1445
+ node.notifyListeners("didUpdate", {
1446
+ layout,
1447
+ snapshot,
1448
+ delta: visualDelta,
1449
+ layoutDelta,
1450
+ hasLayoutChanged,
1451
+ hasRelativeTargetChanged,
1452
+ });
1453
+ }
1454
+ else if (node.isLead()) {
1455
+ const { onExitComplete } = node.options;
1456
+ onExitComplete && onExitComplete();
1457
+ }
1458
+ /**
1459
+ * Clearing transition
1460
+ * TODO: Investigate why this transition is being passed in as {type: false } from Framer
1461
+ * and why we need it at all
1462
+ */
1463
+ node.options.transition = undefined;
1464
+ }
1465
+ function propagateDirtyNodes(node) {
1466
+ /**
1467
+ * Increase debug counter for nodes encountered this frame
1468
+ */
1469
+ if (isDebug) {
1470
+ metrics.totalNodes++;
1471
+ }
1472
+ if (!node.parent)
1473
+ return;
1474
+ /**
1475
+ * If this node isn't projecting, propagate isProjectionDirty. It will have
1476
+ * no performance impact but it will allow the next child that *is* projecting
1477
+ * but *isn't* dirty to just check its parent to see if *any* ancestor needs
1478
+ * correcting.
1479
+ */
1480
+ if (!node.isProjecting()) {
1481
+ node.isProjectionDirty = node.parent.isProjectionDirty;
1482
+ }
1483
+ /**
1484
+ * Propagate isSharedProjectionDirty and isTransformDirty
1485
+ * throughout the whole tree. A future revision can take another look at
1486
+ * this but for safety we still recalcualte shared nodes.
1487
+ */
1488
+ node.isSharedProjectionDirty || (node.isSharedProjectionDirty = Boolean(node.isProjectionDirty ||
1489
+ node.parent.isProjectionDirty ||
1490
+ node.parent.isSharedProjectionDirty));
1491
+ node.isTransformDirty || (node.isTransformDirty = node.parent.isTransformDirty);
1492
+ }
1493
+ function cleanDirtyNodes(node) {
1494
+ node.isProjectionDirty =
1495
+ node.isSharedProjectionDirty =
1496
+ node.isTransformDirty =
1497
+ false;
1498
+ }
1499
+ function clearSnapshot(node) {
1500
+ node.clearSnapshot();
1501
+ }
1502
+ function clearMeasurements(node) {
1503
+ node.clearMeasurements();
1504
+ }
1505
+ function clearIsLayoutDirty(node) {
1506
+ node.isLayoutDirty = false;
1507
+ }
1508
+ function resetTransformStyle(node) {
1509
+ const { visualElement } = node.options;
1510
+ if (visualElement && visualElement.getProps().onBeforeLayoutMeasure) {
1511
+ visualElement.notify("BeforeLayoutMeasure");
1512
+ }
1513
+ node.resetTransform();
1514
+ }
1515
+ function finishAnimation(node) {
1516
+ node.finishAnimation();
1517
+ node.targetDelta = node.relativeTarget = node.target = undefined;
1518
+ node.isProjectionDirty = true;
1519
+ }
1520
+ function resolveTargetDelta(node) {
1521
+ node.resolveTargetDelta();
1522
+ }
1523
+ function calcProjection(node) {
1524
+ node.calcProjection();
1525
+ }
1526
+ function resetSkewAndRotation(node) {
1527
+ node.resetSkewAndRotation();
1528
+ }
1529
+ function removeLeadSnapshots(stack) {
1530
+ stack.removeLeadSnapshot();
1531
+ }
1532
+ function mixAxisDelta(output, delta, p) {
1533
+ output.translate = mixNumber(delta.translate, 0, p);
1534
+ output.scale = mixNumber(delta.scale, 1, p);
1535
+ output.origin = delta.origin;
1536
+ output.originPoint = delta.originPoint;
1537
+ }
1538
+ function mixAxis(output, from, to, p) {
1539
+ output.min = mixNumber(from.min, to.min, p);
1540
+ output.max = mixNumber(from.max, to.max, p);
1541
+ }
1542
+ function mixBox(output, from, to, p) {
1543
+ mixAxis(output.x, from.x, to.x, p);
1544
+ mixAxis(output.y, from.y, to.y, p);
1545
+ }
1546
+ function hasOpacityCrossfade(node) {
1547
+ return (node.animationValues && node.animationValues.opacityExit !== undefined);
1548
+ }
1549
+ const defaultLayoutTransition = {
1550
+ duration: 0.45,
1551
+ ease: [0.4, 0, 0.1, 1],
1552
+ };
1553
+ const userAgentContains = (string) => typeof navigator !== "undefined" &&
1554
+ navigator.userAgent &&
1555
+ navigator.userAgent.toLowerCase().includes(string);
1556
+ /**
1557
+ * Measured bounding boxes must be rounded in Safari and
1558
+ * left untouched in Chrome, otherwise non-integer layouts within scaled-up elements
1559
+ * can appear to jump.
1560
+ */
1561
+ const roundPoint = userAgentContains("applewebkit/") && !userAgentContains("chrome/")
1562
+ ? Math.round
1563
+ : noop;
1564
+ function roundAxis(axis) {
1565
+ // Round to the nearest .5 pixels to support subpixel layouts
1566
+ axis.min = roundPoint(axis.min);
1567
+ axis.max = roundPoint(axis.max);
1568
+ }
1569
+ function roundBox(box) {
1570
+ roundAxis(box.x);
1571
+ roundAxis(box.y);
1572
+ }
1573
+ function shouldAnimatePositionOnly(animationType, snapshot, layout) {
1574
+ return (animationType === "position" ||
1575
+ (animationType === "preserve-aspect" &&
1576
+ !isNear(aspectRatio(snapshot), aspectRatio(layout), 0.2)));
1577
+ }
1578
+ function checkNodeWasScrollRoot(node) {
1579
+ var _a;
1580
+ return node !== node.root && ((_a = node.scroll) === null || _a === void 0 ? void 0 : _a.wasRoot);
1581
+ }
1582
+
1583
+ export { cleanDirtyNodes, createProjectionNode, mixAxis, mixAxisDelta, mixBox, propagateDirtyNodes };