motion 12.18.1 → 12.19.0

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