motion 10.17.1 → 11.11.12
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.
- package/.turbo/turbo-build.log +29 -0
- package/{LICENSE → LICENSE.md} +2 -2
- package/README.md +99 -7
- package/dist/cjs/index.js +6117 -0
- package/dist/cjs/react-client.js +10003 -0
- package/dist/cjs/react-m.js +1852 -0
- package/dist/es/framer-motion/dist/es/animation/GroupPlaybackControls.mjs +78 -0
- package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +34 -0
- package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +19 -0
- package/dist/es/framer-motion/dist/es/animation/animate/sequence.mjs +14 -0
- package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +11 -0
- package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +52 -0
- package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +318 -0
- package/dist/es/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +112 -0
- package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +380 -0
- package/dist/es/framer-motion/dist/es/animation/animators/drivers/driver-frameloop.mjs +17 -0
- package/dist/es/framer-motion/dist/es/animation/animators/utils/accelerated-values.mjs +14 -0
- package/dist/es/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +42 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +169 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +36 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +12 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/easing.mjs +44 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/index.mjs +23 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/attach-timeline.mjs +6 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/get-final-keyframe.mjs +12 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/linear.mjs +15 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/memo-supports.mjs +9 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/style.mjs +8 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-flags.mjs +9 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs +15 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +13 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +5 -0
- package/dist/es/framer-motion/dist/es/animation/generators/inertia.mjs +87 -0
- package/dist/es/framer-motion/dist/es/animation/generators/keyframes.mjs +51 -0
- package/dist/es/framer-motion/dist/es/animation/generators/spring/find.mjs +89 -0
- package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +129 -0
- package/dist/es/framer-motion/dist/es/animation/generators/utils/calc-duration.mjs +17 -0
- package/dist/es/framer-motion/dist/es/animation/generators/utils/is-generator.mjs +5 -0
- package/dist/es/framer-motion/dist/es/animation/generators/utils/velocity.mjs +9 -0
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +105 -0
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +75 -0
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-variant.mjs +66 -0
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element.mjs +26 -0
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/data-id.mjs +6 -0
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/get-appear-id.mjs +7 -0
- package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +230 -0
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-time.mjs +21 -0
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/edit.mjs +31 -0
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/sort.mjs +14 -0
- package/dist/es/framer-motion/dist/es/animation/utils/create-visual-element.mjs +44 -0
- package/dist/es/framer-motion/dist/es/animation/utils/default-transitions.mjs +40 -0
- package/dist/es/framer-motion/dist/es/animation/utils/get-value-transition.mjs +9 -0
- package/dist/es/framer-motion/dist/es/animation/utils/is-animatable.mjs +30 -0
- package/dist/es/framer-motion/dist/es/animation/utils/is-animation-controls.mjs +7 -0
- package/dist/es/framer-motion/dist/es/animation/utils/is-dom-keyframes.mjs +5 -0
- package/dist/es/framer-motion/dist/es/animation/utils/is-keyframes-target.mjs +5 -0
- package/dist/es/framer-motion/dist/es/animation/utils/is-none.mjs +15 -0
- package/dist/es/framer-motion/dist/es/animation/utils/is-transition-defined.mjs +10 -0
- package/dist/es/framer-motion/dist/es/animation/utils/stagger.mjs +26 -0
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs +40 -0
- package/dist/es/framer-motion/dist/es/context/LayoutGroupContext.mjs +6 -0
- package/dist/es/framer-motion/dist/es/context/LazyContext.mjs +6 -0
- package/dist/es/framer-motion/dist/es/context/MotionConfigContext.mjs +13 -0
- package/dist/es/framer-motion/dist/es/context/MotionContext/create.mjs +13 -0
- package/dist/es/framer-motion/dist/es/context/MotionContext/index.mjs +6 -0
- package/dist/es/framer-motion/dist/es/context/MotionContext/utils.mjs +17 -0
- package/dist/es/framer-motion/dist/es/context/PresenceContext.mjs +9 -0
- package/dist/es/framer-motion/dist/es/context/SwitchLayoutGroupContext.mjs +9 -0
- package/dist/es/framer-motion/dist/es/easing/anticipate.mjs +5 -0
- package/dist/es/framer-motion/dist/es/easing/back.mjs +9 -0
- package/dist/es/framer-motion/dist/es/easing/circ.mjs +8 -0
- package/dist/es/framer-motion/dist/es/easing/cubic-bezier.mjs +51 -0
- package/dist/es/framer-motion/dist/es/easing/ease.mjs +7 -0
- package/dist/es/framer-motion/dist/es/easing/modifiers/mirror.mjs +5 -0
- package/dist/es/framer-motion/dist/es/easing/modifiers/reverse.mjs +5 -0
- package/dist/es/framer-motion/dist/es/easing/steps.mjs +15 -0
- package/dist/es/framer-motion/dist/es/easing/utils/create-generator-easing.mjs +17 -0
- package/dist/es/framer-motion/dist/es/easing/utils/get-easing-for-segment.mjs +8 -0
- package/dist/es/framer-motion/dist/es/easing/utils/is-bezier-definition.mjs +3 -0
- package/dist/es/framer-motion/dist/es/easing/utils/is-easing-array.mjs +5 -0
- package/dist/es/framer-motion/dist/es/easing/utils/map.mjs +38 -0
- package/dist/es/framer-motion/dist/es/events/add-dom-event.mjs +6 -0
- package/dist/es/framer-motion/dist/es/events/add-pointer-event.mjs +8 -0
- package/dist/es/framer-motion/dist/es/events/event-info.mjs +15 -0
- package/dist/es/framer-motion/dist/es/events/utils/is-primary-pointer.mjs +18 -0
- package/dist/es/framer-motion/dist/es/frameloop/batcher.mjs +71 -0
- package/dist/es/framer-motion/dist/es/frameloop/frame.mjs +6 -0
- package/dist/es/framer-motion/dist/es/frameloop/index-legacy.mjs +20 -0
- package/dist/es/framer-motion/dist/es/frameloop/microtask.mjs +5 -0
- package/dist/es/framer-motion/dist/es/frameloop/render-step.mjs +80 -0
- package/dist/es/framer-motion/dist/es/frameloop/sync-time.mjs +31 -0
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +487 -0
- package/dist/es/framer-motion/dist/es/gestures/drag/index.mjs +27 -0
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +129 -0
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/lock.mjs +53 -0
- package/dist/es/framer-motion/dist/es/gestures/focus.mjs +41 -0
- package/dist/es/framer-motion/dist/es/gestures/hover.mjs +33 -0
- package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +156 -0
- package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +50 -0
- package/dist/es/framer-motion/dist/es/gestures/press.mjs +130 -0
- package/dist/es/framer-motion/dist/es/gestures/utils/is-node-or-child.mjs +20 -0
- package/dist/es/framer-motion/dist/es/motion/features/Feature.mjs +9 -0
- package/dist/es/framer-motion/dist/es/motion/features/animation/exit.mjs +31 -0
- package/dist/es/framer-motion/dist/es/motion/features/animation/index.mjs +41 -0
- package/dist/es/framer-motion/dist/es/motion/features/animations.mjs +13 -0
- package/dist/es/framer-motion/dist/es/motion/features/definitions.mjs +28 -0
- package/dist/es/framer-motion/dist/es/motion/features/drag.mjs +17 -0
- package/dist/es/framer-motion/dist/es/motion/features/gestures.mjs +21 -0
- package/dist/es/framer-motion/dist/es/motion/features/layout/MeasureLayout.mjs +134 -0
- package/dist/es/framer-motion/dist/es/motion/features/layout.mjs +11 -0
- package/dist/es/framer-motion/dist/es/motion/features/load-features.mjs +12 -0
- package/dist/es/framer-motion/dist/es/motion/features/viewport/index.mjs +72 -0
- package/dist/es/framer-motion/dist/es/motion/features/viewport/observers.mjs +49 -0
- package/dist/es/framer-motion/dist/es/motion/index.mjs +98 -0
- package/dist/es/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +11 -0
- package/dist/es/framer-motion/dist/es/motion/utils/symbol.mjs +3 -0
- package/dist/es/framer-motion/dist/es/motion/utils/use-motion-ref.mjs +36 -0
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +134 -0
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-state.mjs +82 -0
- package/dist/es/framer-motion/dist/es/motion/utils/valid-prop.mjs +57 -0
- package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +93 -0
- package/dist/es/framer-motion/dist/es/projection/geometry/conversion.mjs +33 -0
- package/dist/es/framer-motion/dist/es/projection/geometry/copy.mjs +31 -0
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-apply.mjs +119 -0
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-calc.mjs +52 -0
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-remove.mjs +54 -0
- package/dist/es/framer-motion/dist/es/projection/geometry/models.mjs +17 -0
- package/dist/es/framer-motion/dist/es/projection/geometry/utils.mjs +31 -0
- package/dist/es/framer-motion/dist/es/projection/node/DocumentProjectionNode.mjs +13 -0
- package/dist/es/framer-motion/dist/es/projection/node/HTMLProjectionNode.mjs +27 -0
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +1583 -0
- package/dist/es/framer-motion/dist/es/projection/node/state.mjs +19 -0
- package/dist/es/framer-motion/dist/es/projection/shared/stack.mjs +112 -0
- package/dist/es/framer-motion/dist/es/projection/styles/scale-border-radius.mjs +41 -0
- package/dist/es/framer-motion/dist/es/projection/styles/scale-box-shadow.mjs +35 -0
- package/dist/es/framer-motion/dist/es/projection/styles/scale-correction.mjs +6 -0
- package/dist/es/framer-motion/dist/es/projection/styles/transform.mjs +49 -0
- package/dist/es/framer-motion/dist/es/projection/utils/each-axis.mjs +5 -0
- package/dist/es/framer-motion/dist/es/projection/utils/has-transform.mjs +26 -0
- package/dist/es/framer-motion/dist/es/projection/utils/measure.mjs +17 -0
- package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +477 -0
- package/dist/es/framer-motion/dist/es/render/components/create-factory.mjs +23 -0
- package/dist/es/framer-motion/dist/es/render/components/m/create.mjs +6 -0
- package/dist/es/framer-motion/dist/es/render/components/m/elements.mjs +227 -0
- package/dist/es/framer-motion/dist/es/render/components/motion/create.mjs +15 -0
- package/dist/es/framer-motion/dist/es/render/components/motion/elements.mjs +194 -0
- package/dist/es/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +130 -0
- package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +28 -0
- package/dist/es/framer-motion/dist/es/render/dom/create-visual-element.mjs +14 -0
- package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +64 -0
- package/dist/es/framer-motion/dist/es/render/dom/resize/handle-window.mjs +30 -0
- package/dist/es/framer-motion/dist/es/render/dom/resize/index.mjs +8 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +80 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/info.mjs +56 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/observe.mjs +18 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/edge.mjs +45 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +59 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/inset.mjs +45 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/offset.mjs +35 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/presets.mjs +20 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/on-scroll-handler.mjs +48 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/supports.mjs +5 -0
- package/dist/es/framer-motion/dist/es/render/dom/scroll/track.mjs +84 -0
- package/dist/es/framer-motion/dist/es/render/dom/use-render.mjs +33 -0
- package/dist/es/framer-motion/dist/es/render/dom/utils/camel-to-dash.mjs +6 -0
- package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +42 -0
- package/dist/es/framer-motion/dist/es/render/dom/utils/filter-props.mjs +59 -0
- package/dist/es/framer-motion/dist/es/render/dom/utils/is-css-variable.mjs +15 -0
- package/dist/es/framer-motion/dist/es/render/dom/utils/is-svg-component.mjs +30 -0
- package/dist/es/framer-motion/dist/es/render/dom/utils/is-svg-element.mjs +5 -0
- package/dist/es/framer-motion/dist/es/render/dom/utils/resolve-element.mjs +28 -0
- package/dist/es/framer-motion/dist/es/render/dom/utils/unit-conversion.mjs +65 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/animatable-none.mjs +15 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/defaults.mjs +30 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/dimensions.mjs +15 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/find.mjs +15 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/get-as-type.mjs +10 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/number-browser.mjs +41 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/number.mjs +18 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/test.mjs +6 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/transform.mjs +31 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/type-auto.mjs +9 -0
- package/dist/es/framer-motion/dist/es/render/dom/value-types/type-int.mjs +8 -0
- package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +43 -0
- package/dist/es/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +57 -0
- package/dist/es/framer-motion/dist/es/render/html/config-motion.mjs +12 -0
- package/dist/es/framer-motion/dist/es/render/html/use-props.mjs +57 -0
- package/dist/es/framer-motion/dist/es/render/html/utils/build-styles.mjs +65 -0
- package/dist/es/framer-motion/dist/es/render/html/utils/build-transform.mjs +62 -0
- package/dist/es/framer-motion/dist/es/render/html/utils/create-render-state.mjs +8 -0
- package/dist/es/framer-motion/dist/es/render/html/utils/make-none-animatable.mjs +30 -0
- package/dist/es/framer-motion/dist/es/render/html/utils/render.mjs +9 -0
- package/dist/es/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +20 -0
- package/dist/es/framer-motion/dist/es/render/html/utils/transform.mjs +28 -0
- package/dist/es/framer-motion/dist/es/render/object/ObjectVisualElement.mjs +41 -0
- package/dist/es/framer-motion/dist/es/render/store.mjs +3 -0
- package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +45 -0
- package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +40 -0
- package/dist/es/framer-motion/dist/es/render/svg/lowercase-elements.mjs +33 -0
- package/dist/es/framer-motion/dist/es/render/svg/use-props.mjs +24 -0
- package/dist/es/framer-motion/dist/es/render/svg/utils/build-attrs.mjs +52 -0
- package/dist/es/framer-motion/dist/es/render/svg/utils/camel-case-attrs.mjs +30 -0
- package/dist/es/framer-motion/dist/es/render/svg/utils/create-render-state.mjs +8 -0
- package/dist/es/framer-motion/dist/es/render/svg/utils/is-svg-tag.mjs +3 -0
- package/dist/es/framer-motion/dist/es/render/svg/utils/path.mjs +32 -0
- package/dist/es/framer-motion/dist/es/render/svg/utils/render.mjs +12 -0
- package/dist/es/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +19 -0
- package/dist/es/framer-motion/dist/es/render/svg/utils/transform-origin.mjs +18 -0
- package/dist/es/framer-motion/dist/es/render/utils/KeyframesResolver.mjs +164 -0
- package/dist/es/framer-motion/dist/es/render/utils/animation-state.mjs +332 -0
- package/dist/es/framer-motion/dist/es/render/utils/compare-by-depth.mjs +3 -0
- package/dist/es/framer-motion/dist/es/render/utils/flat-tree.mjs +24 -0
- package/dist/es/framer-motion/dist/es/render/utils/get-variant-context.mjs +28 -0
- package/dist/es/framer-motion/dist/es/render/utils/is-controlling-variants.mjs +13 -0
- package/dist/es/framer-motion/dist/es/render/utils/is-variant-label.mjs +8 -0
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +59 -0
- package/dist/es/framer-motion/dist/es/render/utils/resolve-dynamic-variants.mjs +8 -0
- package/dist/es/framer-motion/dist/es/render/utils/resolve-variants.mjs +36 -0
- package/dist/es/framer-motion/dist/es/render/utils/setters.mjs +27 -0
- package/dist/es/framer-motion/dist/es/render/utils/variant-props.mjs +12 -0
- package/dist/es/framer-motion/dist/es/utils/GlobalConfig.mjs +6 -0
- package/dist/es/framer-motion/dist/es/utils/array.mjs +11 -0
- package/dist/es/framer-motion/dist/es/utils/clamp.mjs +9 -0
- package/dist/es/framer-motion/dist/es/utils/delay.mjs +24 -0
- package/dist/es/framer-motion/dist/es/utils/distance.mjs +9 -0
- package/dist/es/framer-motion/dist/es/utils/errors.mjs +18 -0
- package/dist/es/framer-motion/dist/es/utils/get-context-window.mjs +6 -0
- package/dist/es/framer-motion/dist/es/utils/hsla-to-rgba.mjs +42 -0
- package/dist/es/framer-motion/dist/es/utils/interpolate.mjs +75 -0
- package/dist/es/framer-motion/dist/es/utils/is-browser.mjs +3 -0
- package/dist/es/framer-motion/dist/es/utils/is-numerical-string.mjs +6 -0
- package/dist/es/framer-motion/dist/es/utils/is-ref-object.mjs +7 -0
- package/dist/es/framer-motion/dist/es/utils/is-zero-value-string.mjs +6 -0
- package/dist/es/framer-motion/dist/es/utils/memo.mjs +10 -0
- package/dist/es/framer-motion/dist/es/utils/mix/color.mjs +47 -0
- package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +94 -0
- package/dist/es/framer-motion/dist/es/utils/mix/immediate.mjs +5 -0
- package/dist/es/framer-motion/dist/es/utils/mix/index.mjs +14 -0
- package/dist/es/framer-motion/dist/es/utils/mix/number.mjs +26 -0
- package/dist/es/framer-motion/dist/es/utils/mix/visibility.mjs +16 -0
- package/dist/es/framer-motion/dist/es/utils/noop.mjs +3 -0
- package/dist/es/framer-motion/dist/es/utils/offsets/default.mjs +9 -0
- package/dist/es/framer-motion/dist/es/utils/offsets/fill.mjs +12 -0
- package/dist/es/framer-motion/dist/es/utils/offsets/time.mjs +5 -0
- package/dist/es/framer-motion/dist/es/utils/pipe.mjs +11 -0
- package/dist/es/framer-motion/dist/es/utils/progress.mjs +18 -0
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/index.mjs +19 -0
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/state.mjs +5 -0
- package/dist/es/framer-motion/dist/es/utils/resolve-value.mjs +11 -0
- package/dist/es/framer-motion/dist/es/utils/shallow-compare.mjs +14 -0
- package/dist/es/framer-motion/dist/es/utils/subscription-manager.mjs +40 -0
- package/dist/es/framer-motion/dist/es/utils/time-conversion.mjs +10 -0
- package/dist/es/framer-motion/dist/es/utils/transform.mjs +21 -0
- package/dist/es/framer-motion/dist/es/utils/use-constant.mjs +18 -0
- package/dist/es/framer-motion/dist/es/utils/use-isomorphic-effect.mjs +6 -0
- package/dist/es/framer-motion/dist/es/utils/velocity-per-second.mjs +11 -0
- package/dist/es/framer-motion/dist/es/utils/warn-once.mjs +11 -0
- package/dist/es/framer-motion/dist/es/utils/wrap.mjs +6 -0
- package/dist/es/framer-motion/dist/es/value/index.mjs +313 -0
- package/dist/es/framer-motion/dist/es/value/types/color/hex.mjs +40 -0
- package/dist/es/framer-motion/dist/es/value/types/color/hsla.mjs +22 -0
- package/dist/es/framer-motion/dist/es/value/types/color/index.mjs +27 -0
- package/dist/es/framer-motion/dist/es/value/types/color/rgba.mjs +25 -0
- package/dist/es/framer-motion/dist/es/value/types/color/utils.mjs +29 -0
- package/dist/es/framer-motion/dist/es/value/types/complex/filter.mjs +30 -0
- package/dist/es/framer-motion/dist/es/value/types/complex/index.mjs +92 -0
- package/dist/es/framer-motion/dist/es/value/types/numbers/index.mjs +17 -0
- package/dist/es/framer-motion/dist/es/value/types/numbers/units.mjs +17 -0
- package/dist/es/framer-motion/dist/es/value/types/utils/color-regex.mjs +3 -0
- package/dist/es/framer-motion/dist/es/value/types/utils/float-regex.mjs +3 -0
- package/dist/es/framer-motion/dist/es/value/types/utils/is-nullish.mjs +5 -0
- package/dist/es/framer-motion/dist/es/value/types/utils/sanitize.mjs +5 -0
- package/dist/es/framer-motion/dist/es/value/types/utils/single-color-regex.mjs +3 -0
- package/dist/es/framer-motion/dist/es/value/use-will-change/add-will-change.mjs +14 -0
- package/dist/es/framer-motion/dist/es/value/use-will-change/is.mjs +7 -0
- package/dist/es/framer-motion/dist/es/value/utils/is-motion-value.mjs +3 -0
- package/dist/es/framer-motion/dist/es/value/utils/resolve-motion-value.mjs +16 -0
- package/dist/es/motion/lib/index.mjs +30 -0
- package/dist/es/motion/lib/react-client.mjs +3 -0
- package/dist/es/motion/lib/react-m.mjs +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/motion.dev.js +6121 -0
- package/dist/motion.js +1 -0
- package/dist/react-client.d.ts +1 -0
- package/dist/react-m.d.ts +1 -0
- package/lib/index.js +1 -3
- package/lib/index.js.map +1 -1
- package/lib/react-client.js +3 -0
- package/lib/react-client.js.map +1 -0
- package/lib/react-m.js +3 -0
- package/lib/react-m.js.map +1 -0
- package/lib/react.js +3 -0
- package/lib/react.js.map +1 -0
- package/package.json +79 -29
- package/react/package.json +6 -0
- package/react-client/package.json +6 -0
- package/react-m/package.json +6 -0
- package/rollup.config.mjs +174 -0
- package/src/index.ts +1 -0
- package/src/react-client.ts +3 -0
- package/src/react-m.ts +3 -0
- package/src/react.ts +3 -0
- package/tsconfig.json +25 -0
- package/types/index.d.ts +1 -4
- package/types/react-client.d.ts +1 -0
- package/types/react-m.d.ts +1 -0
- package/types/react.d.ts +1 -0
- package/CHANGELOG.md +0 -372
- package/dist/animate.cjs.js +0 -22
- package/dist/animate.es.js +0 -19
- package/dist/main.cjs.js +0 -21
- package/dist/main.es.js +0 -3
- package/dist/motion.min.js +0 -1
- package/dist/motion.umd.js +0 -2359
- package/dist/size-index.js +0 -1
- package/lib/animate.js +0 -17
- package/lib/animate.js.map +0 -1
- package/types/animate.d.ts +0 -6
- package/types/animate.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useContext, Component } from 'react';
|
|
4
|
+
import { usePresence } from '../../../components/AnimatePresence/use-presence.mjs';
|
|
5
|
+
import { LayoutGroupContext } from '../../../context/LayoutGroupContext.mjs';
|
|
6
|
+
import { SwitchLayoutGroupContext } from '../../../context/SwitchLayoutGroupContext.mjs';
|
|
7
|
+
import { globalProjectionState } from '../../../projection/node/state.mjs';
|
|
8
|
+
import { correctBorderRadius } from '../../../projection/styles/scale-border-radius.mjs';
|
|
9
|
+
import { correctBoxShadow } from '../../../projection/styles/scale-box-shadow.mjs';
|
|
10
|
+
import { addScaleCorrector } from '../../../projection/styles/scale-correction.mjs';
|
|
11
|
+
import { microtask } from '../../../frameloop/microtask.mjs';
|
|
12
|
+
import { frame } from '../../../frameloop/frame.mjs';
|
|
13
|
+
|
|
14
|
+
class MeasureLayoutWithContext extends Component {
|
|
15
|
+
/**
|
|
16
|
+
* This only mounts projection nodes for components that
|
|
17
|
+
* need measuring, we might want to do it for all components
|
|
18
|
+
* in order to incorporate transforms
|
|
19
|
+
*/
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
const { visualElement, layoutGroup, switchLayoutGroup, layoutId } = this.props;
|
|
22
|
+
const { projection } = visualElement;
|
|
23
|
+
addScaleCorrector(defaultScaleCorrectors);
|
|
24
|
+
if (projection) {
|
|
25
|
+
if (layoutGroup.group)
|
|
26
|
+
layoutGroup.group.add(projection);
|
|
27
|
+
if (switchLayoutGroup && switchLayoutGroup.register && layoutId) {
|
|
28
|
+
switchLayoutGroup.register(projection);
|
|
29
|
+
}
|
|
30
|
+
projection.root.didUpdate();
|
|
31
|
+
projection.addEventListener("animationComplete", () => {
|
|
32
|
+
this.safeToRemove();
|
|
33
|
+
});
|
|
34
|
+
projection.setOptions({
|
|
35
|
+
...projection.options,
|
|
36
|
+
onExitComplete: () => this.safeToRemove(),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
globalProjectionState.hasEverUpdated = true;
|
|
40
|
+
}
|
|
41
|
+
getSnapshotBeforeUpdate(prevProps) {
|
|
42
|
+
const { layoutDependency, visualElement, drag, isPresent } = this.props;
|
|
43
|
+
const projection = visualElement.projection;
|
|
44
|
+
if (!projection)
|
|
45
|
+
return null;
|
|
46
|
+
/**
|
|
47
|
+
* TODO: We use this data in relegate to determine whether to
|
|
48
|
+
* promote a previous element. There's no guarantee its presence data
|
|
49
|
+
* will have updated by this point - if a bug like this arises it will
|
|
50
|
+
* have to be that we markForRelegation and then find a new lead some other way,
|
|
51
|
+
* perhaps in didUpdate
|
|
52
|
+
*/
|
|
53
|
+
projection.isPresent = isPresent;
|
|
54
|
+
if (drag ||
|
|
55
|
+
prevProps.layoutDependency !== layoutDependency ||
|
|
56
|
+
layoutDependency === undefined) {
|
|
57
|
+
projection.willUpdate();
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.safeToRemove();
|
|
61
|
+
}
|
|
62
|
+
if (prevProps.isPresent !== isPresent) {
|
|
63
|
+
if (isPresent) {
|
|
64
|
+
projection.promote();
|
|
65
|
+
}
|
|
66
|
+
else if (!projection.relegate()) {
|
|
67
|
+
/**
|
|
68
|
+
* If there's another stack member taking over from this one,
|
|
69
|
+
* it's in charge of the exit animation and therefore should
|
|
70
|
+
* be in charge of the safe to remove. Otherwise we call it here.
|
|
71
|
+
*/
|
|
72
|
+
frame.postRender(() => {
|
|
73
|
+
const stack = projection.getStack();
|
|
74
|
+
if (!stack || !stack.members.length) {
|
|
75
|
+
this.safeToRemove();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
componentDidUpdate() {
|
|
83
|
+
const { projection } = this.props.visualElement;
|
|
84
|
+
if (projection) {
|
|
85
|
+
projection.root.didUpdate();
|
|
86
|
+
microtask.postRender(() => {
|
|
87
|
+
if (!projection.currentAnimation && projection.isLead()) {
|
|
88
|
+
this.safeToRemove();
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
componentWillUnmount() {
|
|
94
|
+
const { visualElement, layoutGroup, switchLayoutGroup: promoteContext, } = this.props;
|
|
95
|
+
const { projection } = visualElement;
|
|
96
|
+
if (projection) {
|
|
97
|
+
projection.scheduleCheckAfterUnmount();
|
|
98
|
+
if (layoutGroup && layoutGroup.group)
|
|
99
|
+
layoutGroup.group.remove(projection);
|
|
100
|
+
if (promoteContext && promoteContext.deregister)
|
|
101
|
+
promoteContext.deregister(projection);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
safeToRemove() {
|
|
105
|
+
const { safeToRemove } = this.props;
|
|
106
|
+
safeToRemove && safeToRemove();
|
|
107
|
+
}
|
|
108
|
+
render() {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function MeasureLayout(props) {
|
|
113
|
+
const [isPresent, safeToRemove] = usePresence();
|
|
114
|
+
const layoutGroup = useContext(LayoutGroupContext);
|
|
115
|
+
return (jsx(MeasureLayoutWithContext, { ...props, layoutGroup: layoutGroup, switchLayoutGroup: useContext(SwitchLayoutGroupContext), isPresent: isPresent, safeToRemove: safeToRemove }));
|
|
116
|
+
}
|
|
117
|
+
const defaultScaleCorrectors = {
|
|
118
|
+
borderRadius: {
|
|
119
|
+
...correctBorderRadius,
|
|
120
|
+
applyTo: [
|
|
121
|
+
"borderTopLeftRadius",
|
|
122
|
+
"borderTopRightRadius",
|
|
123
|
+
"borderBottomLeftRadius",
|
|
124
|
+
"borderBottomRightRadius",
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
borderTopLeftRadius: correctBorderRadius,
|
|
128
|
+
borderTopRightRadius: correctBorderRadius,
|
|
129
|
+
borderBottomLeftRadius: correctBorderRadius,
|
|
130
|
+
borderBottomRightRadius: correctBorderRadius,
|
|
131
|
+
boxShadow: correctBoxShadow,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export { MeasureLayout };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HTMLProjectionNode } from '../../projection/node/HTMLProjectionNode.mjs';
|
|
2
|
+
import { MeasureLayout } from './layout/MeasureLayout.mjs';
|
|
3
|
+
|
|
4
|
+
const layout = {
|
|
5
|
+
layout: {
|
|
6
|
+
ProjectionNode: HTMLProjectionNode,
|
|
7
|
+
MeasureLayout,
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { layout };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Feature } from '../Feature.mjs';
|
|
2
|
+
import { observeIntersection } from './observers.mjs';
|
|
3
|
+
|
|
4
|
+
const thresholdNames = {
|
|
5
|
+
some: 0,
|
|
6
|
+
all: 1,
|
|
7
|
+
};
|
|
8
|
+
class InViewFeature extends Feature {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.hasEnteredView = false;
|
|
12
|
+
this.isInView = false;
|
|
13
|
+
}
|
|
14
|
+
startObserver() {
|
|
15
|
+
this.unmount();
|
|
16
|
+
const { viewport = {} } = this.node.getProps();
|
|
17
|
+
const { root, margin: rootMargin, amount = "some", once } = viewport;
|
|
18
|
+
const options = {
|
|
19
|
+
root: root ? root.current : undefined,
|
|
20
|
+
rootMargin,
|
|
21
|
+
threshold: typeof amount === "number" ? amount : thresholdNames[amount],
|
|
22
|
+
};
|
|
23
|
+
const onIntersectionUpdate = (entry) => {
|
|
24
|
+
const { isIntersecting } = entry;
|
|
25
|
+
/**
|
|
26
|
+
* If there's been no change in the viewport state, early return.
|
|
27
|
+
*/
|
|
28
|
+
if (this.isInView === isIntersecting)
|
|
29
|
+
return;
|
|
30
|
+
this.isInView = isIntersecting;
|
|
31
|
+
/**
|
|
32
|
+
* Handle hasEnteredView. If this is only meant to run once, and
|
|
33
|
+
* element isn't visible, early return. Otherwise set hasEnteredView to true.
|
|
34
|
+
*/
|
|
35
|
+
if (once && !isIntersecting && this.hasEnteredView) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
else if (isIntersecting) {
|
|
39
|
+
this.hasEnteredView = true;
|
|
40
|
+
}
|
|
41
|
+
if (this.node.animationState) {
|
|
42
|
+
this.node.animationState.setActive("whileInView", isIntersecting);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Use the latest committed props rather than the ones in scope
|
|
46
|
+
* when this observer is created
|
|
47
|
+
*/
|
|
48
|
+
const { onViewportEnter, onViewportLeave } = this.node.getProps();
|
|
49
|
+
const callback = isIntersecting ? onViewportEnter : onViewportLeave;
|
|
50
|
+
callback && callback(entry);
|
|
51
|
+
};
|
|
52
|
+
return observeIntersection(this.node.current, options, onIntersectionUpdate);
|
|
53
|
+
}
|
|
54
|
+
mount() {
|
|
55
|
+
this.startObserver();
|
|
56
|
+
}
|
|
57
|
+
update() {
|
|
58
|
+
if (typeof IntersectionObserver === "undefined")
|
|
59
|
+
return;
|
|
60
|
+
const { props, prevProps } = this.node;
|
|
61
|
+
const hasOptionsChanged = ["amount", "margin", "root"].some(hasViewportOptionChanged(props, prevProps));
|
|
62
|
+
if (hasOptionsChanged) {
|
|
63
|
+
this.startObserver();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
unmount() { }
|
|
67
|
+
}
|
|
68
|
+
function hasViewportOptionChanged({ viewport = {} }, { viewport: prevViewport = {} } = {}) {
|
|
69
|
+
return (name) => viewport[name] !== prevViewport[name];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { InViewFeature };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map an IntersectionHandler callback to an element. We only ever make one handler for one
|
|
3
|
+
* element, so even though these handlers might all be triggered by different
|
|
4
|
+
* observers, we can keep them in the same map.
|
|
5
|
+
*/
|
|
6
|
+
const observerCallbacks = new WeakMap();
|
|
7
|
+
/**
|
|
8
|
+
* Multiple observers can be created for multiple element/document roots. Each with
|
|
9
|
+
* different settings. So here we store dictionaries of observers to each root,
|
|
10
|
+
* using serialised settings (threshold/margin) as lookup keys.
|
|
11
|
+
*/
|
|
12
|
+
const observers = new WeakMap();
|
|
13
|
+
const fireObserverCallback = (entry) => {
|
|
14
|
+
const callback = observerCallbacks.get(entry.target);
|
|
15
|
+
callback && callback(entry);
|
|
16
|
+
};
|
|
17
|
+
const fireAllObserverCallbacks = (entries) => {
|
|
18
|
+
entries.forEach(fireObserverCallback);
|
|
19
|
+
};
|
|
20
|
+
function initIntersectionObserver({ root, ...options }) {
|
|
21
|
+
const lookupRoot = root || document;
|
|
22
|
+
/**
|
|
23
|
+
* If we don't have an observer lookup map for this root, create one.
|
|
24
|
+
*/
|
|
25
|
+
if (!observers.has(lookupRoot)) {
|
|
26
|
+
observers.set(lookupRoot, {});
|
|
27
|
+
}
|
|
28
|
+
const rootObservers = observers.get(lookupRoot);
|
|
29
|
+
const key = JSON.stringify(options);
|
|
30
|
+
/**
|
|
31
|
+
* If we don't have an observer for this combination of root and settings,
|
|
32
|
+
* create one.
|
|
33
|
+
*/
|
|
34
|
+
if (!rootObservers[key]) {
|
|
35
|
+
rootObservers[key] = new IntersectionObserver(fireAllObserverCallbacks, { root, ...options });
|
|
36
|
+
}
|
|
37
|
+
return rootObservers[key];
|
|
38
|
+
}
|
|
39
|
+
function observeIntersection(element, options, callback) {
|
|
40
|
+
const rootInteresectionObserver = initIntersectionObserver(options);
|
|
41
|
+
observerCallbacks.set(element, callback);
|
|
42
|
+
rootInteresectionObserver.observe(element);
|
|
43
|
+
return () => {
|
|
44
|
+
observerCallbacks.delete(element);
|
|
45
|
+
rootInteresectionObserver.unobserve(element);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { observeIntersection };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, useContext } from 'react';
|
|
4
|
+
import { MotionConfigContext } from '../context/MotionConfigContext.mjs';
|
|
5
|
+
import { MotionContext } from '../context/MotionContext/index.mjs';
|
|
6
|
+
import { useVisualElement } from './utils/use-visual-element.mjs';
|
|
7
|
+
import { useMotionRef } from './utils/use-motion-ref.mjs';
|
|
8
|
+
import { useCreateMotionContext } from '../context/MotionContext/create.mjs';
|
|
9
|
+
import { loadFeatures } from './features/load-features.mjs';
|
|
10
|
+
import { isBrowser } from '../utils/is-browser.mjs';
|
|
11
|
+
import { LayoutGroupContext } from '../context/LayoutGroupContext.mjs';
|
|
12
|
+
import { LazyContext } from '../context/LazyContext.mjs';
|
|
13
|
+
import { motionComponentSymbol } from './utils/symbol.mjs';
|
|
14
|
+
import { warning, invariant } from '../utils/errors.mjs';
|
|
15
|
+
import { featureDefinitions } from './features/definitions.mjs';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Create a `motion` component.
|
|
19
|
+
*
|
|
20
|
+
* This function accepts a Component argument, which can be either a string (ie "div"
|
|
21
|
+
* for `motion.div`), or an actual React component.
|
|
22
|
+
*
|
|
23
|
+
* Alongside this is a config option which provides a way of rendering the provided
|
|
24
|
+
* component "offline", or outside the React render cycle.
|
|
25
|
+
*/
|
|
26
|
+
function createRendererMotionComponent({ preloadedFeatures, createVisualElement, useRender, useVisualState, Component, }) {
|
|
27
|
+
preloadedFeatures && loadFeatures(preloadedFeatures);
|
|
28
|
+
function MotionComponent(props, externalRef) {
|
|
29
|
+
/**
|
|
30
|
+
* If we need to measure the element we load this functionality in a
|
|
31
|
+
* separate class component in order to gain access to getSnapshotBeforeUpdate.
|
|
32
|
+
*/
|
|
33
|
+
let MeasureLayout;
|
|
34
|
+
const configAndProps = {
|
|
35
|
+
...useContext(MotionConfigContext),
|
|
36
|
+
...props,
|
|
37
|
+
layoutId: useLayoutId(props),
|
|
38
|
+
};
|
|
39
|
+
const { isStatic } = configAndProps;
|
|
40
|
+
const context = useCreateMotionContext(props);
|
|
41
|
+
const visualState = useVisualState(props, isStatic);
|
|
42
|
+
if (!isStatic && isBrowser) {
|
|
43
|
+
useStrictMode(configAndProps, preloadedFeatures);
|
|
44
|
+
const layoutProjection = getProjectionFunctionality(configAndProps);
|
|
45
|
+
MeasureLayout = layoutProjection.MeasureLayout;
|
|
46
|
+
/**
|
|
47
|
+
* Create a VisualElement for this component. A VisualElement provides a common
|
|
48
|
+
* interface to renderer-specific APIs (ie DOM/Three.js etc) as well as
|
|
49
|
+
* providing a way of rendering to these APIs outside of the React render loop
|
|
50
|
+
* for more performant animations and interactions
|
|
51
|
+
*/
|
|
52
|
+
context.visualElement = useVisualElement(Component, visualState, configAndProps, createVisualElement, layoutProjection.ProjectionNode);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The mount order and hierarchy is specific to ensure our element ref
|
|
56
|
+
* is hydrated by the time features fire their effects.
|
|
57
|
+
*/
|
|
58
|
+
return (jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout && context.visualElement ? (jsx(MeasureLayout, { visualElement: context.visualElement, ...configAndProps })) : null, useRender(Component, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement)] }));
|
|
59
|
+
}
|
|
60
|
+
const ForwardRefMotionComponent = forwardRef(MotionComponent);
|
|
61
|
+
ForwardRefMotionComponent[motionComponentSymbol] = Component;
|
|
62
|
+
return ForwardRefMotionComponent;
|
|
63
|
+
}
|
|
64
|
+
function useLayoutId({ layoutId }) {
|
|
65
|
+
const layoutGroupId = useContext(LayoutGroupContext).id;
|
|
66
|
+
return layoutGroupId && layoutId !== undefined
|
|
67
|
+
? layoutGroupId + "-" + layoutId
|
|
68
|
+
: layoutId;
|
|
69
|
+
}
|
|
70
|
+
function useStrictMode(configAndProps, preloadedFeatures) {
|
|
71
|
+
const isStrict = useContext(LazyContext).strict;
|
|
72
|
+
/**
|
|
73
|
+
* If we're in development mode, check to make sure we're not rendering a motion component
|
|
74
|
+
* as a child of LazyMotion, as this will break the file-size benefits of using it.
|
|
75
|
+
*/
|
|
76
|
+
if (process.env.NODE_ENV !== "production" &&
|
|
77
|
+
preloadedFeatures &&
|
|
78
|
+
isStrict) {
|
|
79
|
+
const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
|
|
80
|
+
configAndProps.ignoreStrict
|
|
81
|
+
? warning(false, strictMessage)
|
|
82
|
+
: invariant(false, strictMessage);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function getProjectionFunctionality(props) {
|
|
86
|
+
const { drag, layout } = featureDefinitions;
|
|
87
|
+
if (!drag && !layout)
|
|
88
|
+
return {};
|
|
89
|
+
const combined = { ...drag, ...layout };
|
|
90
|
+
return {
|
|
91
|
+
MeasureLayout: (drag === null || drag === void 0 ? void 0 : drag.isEnabled(props)) || (layout === null || layout === void 0 ? void 0 : layout.isEnabled(props))
|
|
92
|
+
? combined.MeasureLayout
|
|
93
|
+
: undefined,
|
|
94
|
+
ProjectionNode: combined.ProjectionNode,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { createRendererMotionComponent };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { scaleCorrectors } from '../../projection/styles/scale-correction.mjs';
|
|
2
|
+
import { transformProps } from '../../render/html/utils/transform.mjs';
|
|
3
|
+
|
|
4
|
+
function isForcedMotionValue(key, { layout, layoutId }) {
|
|
5
|
+
return (transformProps.has(key) ||
|
|
6
|
+
key.startsWith("origin") ||
|
|
7
|
+
((layout || layoutId !== undefined) &&
|
|
8
|
+
(!!scaleCorrectors[key] || key === "opacity")));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { isForcedMotionValue };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { isRefObject } from '../../utils/is-ref-object.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a ref function that, when called, hydrates the provided
|
|
6
|
+
* external ref and VisualElement.
|
|
7
|
+
*/
|
|
8
|
+
function useMotionRef(visualState, visualElement, externalRef) {
|
|
9
|
+
return useCallback((instance) => {
|
|
10
|
+
instance && visualState.mount && visualState.mount(instance);
|
|
11
|
+
if (visualElement) {
|
|
12
|
+
if (instance) {
|
|
13
|
+
visualElement.mount(instance);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
visualElement.unmount();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (externalRef) {
|
|
20
|
+
if (typeof externalRef === "function") {
|
|
21
|
+
externalRef(instance);
|
|
22
|
+
}
|
|
23
|
+
else if (isRefObject(externalRef)) {
|
|
24
|
+
externalRef.current = instance;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* Only pass a new ref callback to React if we've received a visual element
|
|
30
|
+
* factory. Otherwise we'll be mounting/remounting every time externalRef
|
|
31
|
+
* or other dependencies change.
|
|
32
|
+
*/
|
|
33
|
+
[visualElement]);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { useMotionRef };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { useContext, useRef, useInsertionEffect, useEffect } from 'react';
|
|
2
|
+
import { PresenceContext } from '../../context/PresenceContext.mjs';
|
|
3
|
+
import { MotionContext } from '../../context/MotionContext/index.mjs';
|
|
4
|
+
import { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';
|
|
5
|
+
import { LazyContext } from '../../context/LazyContext.mjs';
|
|
6
|
+
import { MotionConfigContext } from '../../context/MotionConfigContext.mjs';
|
|
7
|
+
import { optimizedAppearDataAttribute } from '../../animation/optimized-appear/data-id.mjs';
|
|
8
|
+
import { microtask } from '../../frameloop/microtask.mjs';
|
|
9
|
+
import { isRefObject } from '../../utils/is-ref-object.mjs';
|
|
10
|
+
import { SwitchLayoutGroupContext } from '../../context/SwitchLayoutGroupContext.mjs';
|
|
11
|
+
|
|
12
|
+
function useVisualElement(Component, visualState, props, createVisualElement, ProjectionNodeConstructor) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const { visualElement: parent } = useContext(MotionContext);
|
|
15
|
+
const lazyContext = useContext(LazyContext);
|
|
16
|
+
const presenceContext = useContext(PresenceContext);
|
|
17
|
+
const reducedMotionConfig = useContext(MotionConfigContext).reducedMotion;
|
|
18
|
+
const visualElementRef = useRef();
|
|
19
|
+
/**
|
|
20
|
+
* If we haven't preloaded a renderer, check to see if we have one lazy-loaded
|
|
21
|
+
*/
|
|
22
|
+
createVisualElement = createVisualElement || lazyContext.renderer;
|
|
23
|
+
if (!visualElementRef.current && createVisualElement) {
|
|
24
|
+
visualElementRef.current = createVisualElement(Component, {
|
|
25
|
+
visualState,
|
|
26
|
+
parent,
|
|
27
|
+
props,
|
|
28
|
+
presenceContext,
|
|
29
|
+
blockInitialAnimation: presenceContext
|
|
30
|
+
? presenceContext.initial === false
|
|
31
|
+
: false,
|
|
32
|
+
reducedMotionConfig,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const visualElement = visualElementRef.current;
|
|
36
|
+
/**
|
|
37
|
+
* Load Motion gesture and animation features. These are rendered as renderless
|
|
38
|
+
* components so each feature can optionally make use of React lifecycle methods.
|
|
39
|
+
*/
|
|
40
|
+
const initialLayoutGroupConfig = useContext(SwitchLayoutGroupContext);
|
|
41
|
+
if (visualElement &&
|
|
42
|
+
!visualElement.projection &&
|
|
43
|
+
ProjectionNodeConstructor &&
|
|
44
|
+
(visualElement.type === "html" || visualElement.type === "svg")) {
|
|
45
|
+
createProjectionNode(visualElementRef.current, props, ProjectionNodeConstructor, initialLayoutGroupConfig);
|
|
46
|
+
}
|
|
47
|
+
const isMounted = useRef(false);
|
|
48
|
+
useInsertionEffect(() => {
|
|
49
|
+
/**
|
|
50
|
+
* Check the component has already mounted before calling
|
|
51
|
+
* `update` unnecessarily. This ensures we skip the initial update.
|
|
52
|
+
*/
|
|
53
|
+
if (visualElement && isMounted.current) {
|
|
54
|
+
visualElement.update(props, presenceContext);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Cache this value as we want to know whether HandoffAppearAnimations
|
|
59
|
+
* was present on initial render - it will be deleted after this.
|
|
60
|
+
*/
|
|
61
|
+
const optimisedAppearId = props[optimizedAppearDataAttribute];
|
|
62
|
+
const wantsHandoff = useRef(Boolean(optimisedAppearId) &&
|
|
63
|
+
!((_a = window.MotionHandoffIsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId)) &&
|
|
64
|
+
((_b = window.MotionHasOptimisedAnimation) === null || _b === void 0 ? void 0 : _b.call(window, optimisedAppearId)));
|
|
65
|
+
useIsomorphicLayoutEffect(() => {
|
|
66
|
+
if (!visualElement)
|
|
67
|
+
return;
|
|
68
|
+
isMounted.current = true;
|
|
69
|
+
window.MotionIsMounted = true;
|
|
70
|
+
visualElement.updateFeatures();
|
|
71
|
+
microtask.render(visualElement.render);
|
|
72
|
+
/**
|
|
73
|
+
* Ideally this function would always run in a useEffect.
|
|
74
|
+
*
|
|
75
|
+
* However, if we have optimised appear animations to handoff from,
|
|
76
|
+
* it needs to happen synchronously to ensure there's no flash of
|
|
77
|
+
* incorrect styles in the event of a hydration error.
|
|
78
|
+
*
|
|
79
|
+
* So if we detect a situtation where optimised appear animations
|
|
80
|
+
* are running, we use useLayoutEffect to trigger animations.
|
|
81
|
+
*/
|
|
82
|
+
if (wantsHandoff.current && visualElement.animationState) {
|
|
83
|
+
visualElement.animationState.animateChanges();
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (!visualElement)
|
|
88
|
+
return;
|
|
89
|
+
if (!wantsHandoff.current && visualElement.animationState) {
|
|
90
|
+
visualElement.animationState.animateChanges();
|
|
91
|
+
}
|
|
92
|
+
if (wantsHandoff.current) {
|
|
93
|
+
// This ensures all future calls to animateChanges() in this component will run in useEffect
|
|
94
|
+
queueMicrotask(() => {
|
|
95
|
+
var _a;
|
|
96
|
+
(_a = window.MotionHandoffMarkAsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId);
|
|
97
|
+
});
|
|
98
|
+
wantsHandoff.current = false;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return visualElement;
|
|
102
|
+
}
|
|
103
|
+
function createProjectionNode(visualElement, props, ProjectionNodeConstructor, initialPromotionConfig) {
|
|
104
|
+
const { layoutId, layout, drag, dragConstraints, layoutScroll, layoutRoot, } = props;
|
|
105
|
+
visualElement.projection = new ProjectionNodeConstructor(visualElement.latestValues, props["data-framer-portal-id"]
|
|
106
|
+
? undefined
|
|
107
|
+
: getClosestProjectingNode(visualElement.parent));
|
|
108
|
+
visualElement.projection.setOptions({
|
|
109
|
+
layoutId,
|
|
110
|
+
layout,
|
|
111
|
+
alwaysMeasureLayout: Boolean(drag) || (dragConstraints && isRefObject(dragConstraints)),
|
|
112
|
+
visualElement,
|
|
113
|
+
/**
|
|
114
|
+
* TODO: Update options in an effect. This could be tricky as it'll be too late
|
|
115
|
+
* to update by the time layout animations run.
|
|
116
|
+
* We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
|
|
117
|
+
* ensuring it gets called if there's no potential layout animations.
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
120
|
+
animationType: typeof layout === "string" ? layout : "both",
|
|
121
|
+
initialPromotionConfig,
|
|
122
|
+
layoutScroll,
|
|
123
|
+
layoutRoot,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function getClosestProjectingNode(visualElement) {
|
|
127
|
+
if (!visualElement)
|
|
128
|
+
return undefined;
|
|
129
|
+
return visualElement.options.allowProjection !== false
|
|
130
|
+
? visualElement.projection
|
|
131
|
+
: getClosestProjectingNode(visualElement.parent);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { useVisualElement };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { isAnimationControls } from '../../animation/utils/is-animation-controls.mjs';
|
|
3
|
+
import { PresenceContext } from '../../context/PresenceContext.mjs';
|
|
4
|
+
import { resolveVariantFromProps } from '../../render/utils/resolve-variants.mjs';
|
|
5
|
+
import { useConstant } from '../../utils/use-constant.mjs';
|
|
6
|
+
import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
|
|
7
|
+
import { MotionContext } from '../../context/MotionContext/index.mjs';
|
|
8
|
+
import { isControllingVariants, isVariantNode } from '../../render/utils/is-controlling-variants.mjs';
|
|
9
|
+
|
|
10
|
+
function makeState({ scrapeMotionValuesFromProps, createRenderState, onMount, }, props, context, presenceContext) {
|
|
11
|
+
const state = {
|
|
12
|
+
latestValues: makeLatestValues(props, context, presenceContext, scrapeMotionValuesFromProps),
|
|
13
|
+
renderState: createRenderState(),
|
|
14
|
+
};
|
|
15
|
+
if (onMount) {
|
|
16
|
+
state.mount = (instance) => onMount(props, instance, state);
|
|
17
|
+
}
|
|
18
|
+
return state;
|
|
19
|
+
}
|
|
20
|
+
const makeUseVisualState = (config) => (props, isStatic) => {
|
|
21
|
+
const context = useContext(MotionContext);
|
|
22
|
+
const presenceContext = useContext(PresenceContext);
|
|
23
|
+
const make = () => makeState(config, props, context, presenceContext);
|
|
24
|
+
return isStatic ? make() : useConstant(make);
|
|
25
|
+
};
|
|
26
|
+
function makeLatestValues(props, context, presenceContext, scrapeMotionValues) {
|
|
27
|
+
const values = {};
|
|
28
|
+
const motionValues = scrapeMotionValues(props, {});
|
|
29
|
+
for (const key in motionValues) {
|
|
30
|
+
values[key] = resolveMotionValue(motionValues[key]);
|
|
31
|
+
}
|
|
32
|
+
let { initial, animate } = props;
|
|
33
|
+
const isControllingVariants$1 = isControllingVariants(props);
|
|
34
|
+
const isVariantNode$1 = isVariantNode(props);
|
|
35
|
+
if (context &&
|
|
36
|
+
isVariantNode$1 &&
|
|
37
|
+
!isControllingVariants$1 &&
|
|
38
|
+
props.inherit !== false) {
|
|
39
|
+
if (initial === undefined)
|
|
40
|
+
initial = context.initial;
|
|
41
|
+
if (animate === undefined)
|
|
42
|
+
animate = context.animate;
|
|
43
|
+
}
|
|
44
|
+
let isInitialAnimationBlocked = presenceContext
|
|
45
|
+
? presenceContext.initial === false
|
|
46
|
+
: false;
|
|
47
|
+
isInitialAnimationBlocked = isInitialAnimationBlocked || initial === false;
|
|
48
|
+
const variantToSet = isInitialAnimationBlocked ? animate : initial;
|
|
49
|
+
if (variantToSet &&
|
|
50
|
+
typeof variantToSet !== "boolean" &&
|
|
51
|
+
!isAnimationControls(variantToSet)) {
|
|
52
|
+
const list = Array.isArray(variantToSet) ? variantToSet : [variantToSet];
|
|
53
|
+
for (let i = 0; i < list.length; i++) {
|
|
54
|
+
const resolved = resolveVariantFromProps(props, list[i]);
|
|
55
|
+
if (resolved) {
|
|
56
|
+
const { transitionEnd, transition, ...target } = resolved;
|
|
57
|
+
for (const key in target) {
|
|
58
|
+
let valueTarget = target[key];
|
|
59
|
+
if (Array.isArray(valueTarget)) {
|
|
60
|
+
/**
|
|
61
|
+
* Take final keyframe if the initial animation is blocked because
|
|
62
|
+
* we want to initialise at the end of that blocked animation.
|
|
63
|
+
*/
|
|
64
|
+
const index = isInitialAnimationBlocked
|
|
65
|
+
? valueTarget.length - 1
|
|
66
|
+
: 0;
|
|
67
|
+
valueTarget = valueTarget[index];
|
|
68
|
+
}
|
|
69
|
+
if (valueTarget !== null) {
|
|
70
|
+
values[key] = valueTarget;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (const key in transitionEnd) {
|
|
74
|
+
values[key] = transitionEnd[key];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return values;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { makeUseVisualState };
|