motion 10.18.0 → 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 -378
- 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 -2364
- 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,44 @@
|
|
|
1
|
+
import { isBezierDefinition } from '../../../easing/utils/is-bezier-definition.mjs';
|
|
2
|
+
import { generateLinearEasing } from './utils/linear.mjs';
|
|
3
|
+
import { supportsLinearEasing } from './utils/supports-linear-easing.mjs';
|
|
4
|
+
|
|
5
|
+
function isWaapiSupportedEasing(easing) {
|
|
6
|
+
return Boolean((typeof easing === "function" && supportsLinearEasing()) ||
|
|
7
|
+
!easing ||
|
|
8
|
+
(typeof easing === "string" &&
|
|
9
|
+
(easing in supportedWaapiEasing || supportsLinearEasing())) ||
|
|
10
|
+
isBezierDefinition(easing) ||
|
|
11
|
+
(Array.isArray(easing) && easing.every(isWaapiSupportedEasing)));
|
|
12
|
+
}
|
|
13
|
+
const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
|
|
14
|
+
const supportedWaapiEasing = {
|
|
15
|
+
linear: "linear",
|
|
16
|
+
ease: "ease",
|
|
17
|
+
easeIn: "ease-in",
|
|
18
|
+
easeOut: "ease-out",
|
|
19
|
+
easeInOut: "ease-in-out",
|
|
20
|
+
circIn: /*@__PURE__*/ cubicBezierAsString([0, 0.65, 0.55, 1]),
|
|
21
|
+
circOut: /*@__PURE__*/ cubicBezierAsString([0.55, 0, 1, 0.45]),
|
|
22
|
+
backIn: /*@__PURE__*/ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
|
|
23
|
+
backOut: /*@__PURE__*/ cubicBezierAsString([0.33, 1.53, 0.69, 0.99]),
|
|
24
|
+
};
|
|
25
|
+
function mapEasingToNativeEasing(easing, duration) {
|
|
26
|
+
if (!easing) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
else if (typeof easing === "function" && supportsLinearEasing()) {
|
|
30
|
+
return generateLinearEasing(easing, duration);
|
|
31
|
+
}
|
|
32
|
+
else if (isBezierDefinition(easing)) {
|
|
33
|
+
return cubicBezierAsString(easing);
|
|
34
|
+
}
|
|
35
|
+
else if (Array.isArray(easing)) {
|
|
36
|
+
return easing.map((segmentEasing) => mapEasingToNativeEasing(segmentEasing, duration) ||
|
|
37
|
+
supportedWaapiEasing.easeOut);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return supportedWaapiEasing[easing];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { cubicBezierAsString, isWaapiSupportedEasing, mapEasingToNativeEasing, supportedWaapiEasing };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { mapEasingToNativeEasing } from './easing.mjs';
|
|
2
|
+
|
|
3
|
+
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
|
|
4
|
+
const keyframeOptions = { [valueName]: keyframes };
|
|
5
|
+
if (times)
|
|
6
|
+
keyframeOptions.offset = times;
|
|
7
|
+
const easing = mapEasingToNativeEasing(ease, duration);
|
|
8
|
+
/**
|
|
9
|
+
* If this is an easing array, apply to keyframes, not animation as a whole
|
|
10
|
+
*/
|
|
11
|
+
if (Array.isArray(easing))
|
|
12
|
+
keyframeOptions.easing = easing;
|
|
13
|
+
return element.animate(keyframeOptions, {
|
|
14
|
+
delay,
|
|
15
|
+
duration,
|
|
16
|
+
easing: !Array.isArray(easing) ? easing : "linear",
|
|
17
|
+
fill: "both",
|
|
18
|
+
iterations: repeat + 1,
|
|
19
|
+
direction: repeatType === "reverse" ? "alternate" : "normal",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { startWaapiAnimation };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const isNotNull = (value) => value !== null;
|
|
2
|
+
function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe) {
|
|
3
|
+
const resolvedKeyframes = keyframes.filter(isNotNull);
|
|
4
|
+
const index = repeat && repeatType !== "loop" && repeat % 2 === 1
|
|
5
|
+
? 0
|
|
6
|
+
: resolvedKeyframes.length - 1;
|
|
7
|
+
return !index || finalKeyframe === undefined
|
|
8
|
+
? resolvedKeyframes[index]
|
|
9
|
+
: finalKeyframe;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { getFinalKeyframe };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { progress } from '../../../../utils/progress.mjs';
|
|
2
|
+
|
|
3
|
+
// Create a linear easing point for every 10 ms
|
|
4
|
+
const resolution = 10;
|
|
5
|
+
const generateLinearEasing = (easing, duration // as milliseconds
|
|
6
|
+
) => {
|
|
7
|
+
let points = "";
|
|
8
|
+
const numPoints = Math.max(Math.round(duration / resolution), 2);
|
|
9
|
+
for (let i = 0; i < numPoints; i++) {
|
|
10
|
+
points += easing(progress(0, numPoints - 1, i)) + ", ";
|
|
11
|
+
}
|
|
12
|
+
return `linear(${points.substring(0, points.length - 2)})`;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { generateLinearEasing };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { memo } from '../../../../utils/memo.mjs';
|
|
2
|
+
import { supportsFlags } from './supports-flags.mjs';
|
|
3
|
+
|
|
4
|
+
function memoSupports(callback, supportsFlag) {
|
|
5
|
+
const memoized = memo(callback);
|
|
6
|
+
return () => { var _a; return (_a = supportsFlags[supportsFlag]) !== null && _a !== void 0 ? _a : memoized(); };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { memoSupports };
|
package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { memoSupports } from './memo-supports.mjs';
|
|
2
|
+
|
|
3
|
+
const supportsLinearEasing = /*@__PURE__*/ memoSupports(() => {
|
|
4
|
+
try {
|
|
5
|
+
document
|
|
6
|
+
.createElement("div")
|
|
7
|
+
.animate({ opacity: 0 }, { easing: "linear(0, 1)" });
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
|
+
}, "linearEasing");
|
|
14
|
+
|
|
15
|
+
export { supportsLinearEasing };
|
package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { memo } from '../../../../utils/memo.mjs';
|
|
2
|
+
|
|
3
|
+
const supportsPartialKeyframes = /*@__PURE__*/ memo(() => {
|
|
4
|
+
try {
|
|
5
|
+
document.createElement("div").animate({ opacity: [1] });
|
|
6
|
+
}
|
|
7
|
+
catch (e) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return true;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { supportsPartialKeyframes };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { spring } from './spring/index.mjs';
|
|
2
|
+
import { calcGeneratorVelocity } from './utils/velocity.mjs';
|
|
3
|
+
|
|
4
|
+
function inertia({ keyframes, velocity = 0.0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed, }) {
|
|
5
|
+
const origin = keyframes[0];
|
|
6
|
+
const state = {
|
|
7
|
+
done: false,
|
|
8
|
+
value: origin,
|
|
9
|
+
};
|
|
10
|
+
const isOutOfBounds = (v) => (min !== undefined && v < min) || (max !== undefined && v > max);
|
|
11
|
+
const nearestBoundary = (v) => {
|
|
12
|
+
if (min === undefined)
|
|
13
|
+
return max;
|
|
14
|
+
if (max === undefined)
|
|
15
|
+
return min;
|
|
16
|
+
return Math.abs(min - v) < Math.abs(max - v) ? min : max;
|
|
17
|
+
};
|
|
18
|
+
let amplitude = power * velocity;
|
|
19
|
+
const ideal = origin + amplitude;
|
|
20
|
+
const target = modifyTarget === undefined ? ideal : modifyTarget(ideal);
|
|
21
|
+
/**
|
|
22
|
+
* If the target has changed we need to re-calculate the amplitude, otherwise
|
|
23
|
+
* the animation will start from the wrong position.
|
|
24
|
+
*/
|
|
25
|
+
if (target !== ideal)
|
|
26
|
+
amplitude = target - origin;
|
|
27
|
+
const calcDelta = (t) => -amplitude * Math.exp(-t / timeConstant);
|
|
28
|
+
const calcLatest = (t) => target + calcDelta(t);
|
|
29
|
+
const applyFriction = (t) => {
|
|
30
|
+
const delta = calcDelta(t);
|
|
31
|
+
const latest = calcLatest(t);
|
|
32
|
+
state.done = Math.abs(delta) <= restDelta;
|
|
33
|
+
state.value = state.done ? target : latest;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Ideally this would resolve for t in a stateless way, we could
|
|
37
|
+
* do that by always precalculating the animation but as we know
|
|
38
|
+
* this will be done anyway we can assume that spring will
|
|
39
|
+
* be discovered during that.
|
|
40
|
+
*/
|
|
41
|
+
let timeReachedBoundary;
|
|
42
|
+
let spring$1;
|
|
43
|
+
const checkCatchBoundary = (t) => {
|
|
44
|
+
if (!isOutOfBounds(state.value))
|
|
45
|
+
return;
|
|
46
|
+
timeReachedBoundary = t;
|
|
47
|
+
spring$1 = spring({
|
|
48
|
+
keyframes: [state.value, nearestBoundary(state.value)],
|
|
49
|
+
velocity: calcGeneratorVelocity(calcLatest, t, state.value), // TODO: This should be passing * 1000
|
|
50
|
+
damping: bounceDamping,
|
|
51
|
+
stiffness: bounceStiffness,
|
|
52
|
+
restDelta,
|
|
53
|
+
restSpeed,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
checkCatchBoundary(0);
|
|
57
|
+
return {
|
|
58
|
+
calculatedDuration: null,
|
|
59
|
+
next: (t) => {
|
|
60
|
+
/**
|
|
61
|
+
* We need to resolve the friction to figure out if we need a
|
|
62
|
+
* spring but we don't want to do this twice per frame. So here
|
|
63
|
+
* we flag if we updated for this frame and later if we did
|
|
64
|
+
* we can skip doing it again.
|
|
65
|
+
*/
|
|
66
|
+
let hasUpdatedFrame = false;
|
|
67
|
+
if (!spring$1 && timeReachedBoundary === undefined) {
|
|
68
|
+
hasUpdatedFrame = true;
|
|
69
|
+
applyFriction(t);
|
|
70
|
+
checkCatchBoundary(t);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* If we have a spring and the provided t is beyond the moment the friction
|
|
74
|
+
* animation crossed the min/max boundary, use the spring.
|
|
75
|
+
*/
|
|
76
|
+
if (timeReachedBoundary !== undefined && t >= timeReachedBoundary) {
|
|
77
|
+
return spring$1.next(t - timeReachedBoundary);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
!hasUpdatedFrame && applyFriction(t);
|
|
81
|
+
return state;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { inertia };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { easeInOut } from '../../easing/ease.mjs';
|
|
2
|
+
import { isEasingArray } from '../../easing/utils/is-easing-array.mjs';
|
|
3
|
+
import { easingDefinitionToFunction } from '../../easing/utils/map.mjs';
|
|
4
|
+
import { interpolate } from '../../utils/interpolate.mjs';
|
|
5
|
+
import { defaultOffset } from '../../utils/offsets/default.mjs';
|
|
6
|
+
import { convertOffsetToTimes } from '../../utils/offsets/time.mjs';
|
|
7
|
+
|
|
8
|
+
function defaultEasing(values, easing) {
|
|
9
|
+
return values.map(() => easing || easeInOut).splice(0, values.length - 1);
|
|
10
|
+
}
|
|
11
|
+
function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut", }) {
|
|
12
|
+
/**
|
|
13
|
+
* Easing functions can be externally defined as strings. Here we convert them
|
|
14
|
+
* into actual functions.
|
|
15
|
+
*/
|
|
16
|
+
const easingFunctions = isEasingArray(ease)
|
|
17
|
+
? ease.map(easingDefinitionToFunction)
|
|
18
|
+
: easingDefinitionToFunction(ease);
|
|
19
|
+
/**
|
|
20
|
+
* This is the Iterator-spec return value. We ensure it's mutable rather than using a generator
|
|
21
|
+
* to reduce GC during animation.
|
|
22
|
+
*/
|
|
23
|
+
const state = {
|
|
24
|
+
done: false,
|
|
25
|
+
value: keyframeValues[0],
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Create a times array based on the provided 0-1 offsets
|
|
29
|
+
*/
|
|
30
|
+
const absoluteTimes = convertOffsetToTimes(
|
|
31
|
+
// Only use the provided offsets if they're the correct length
|
|
32
|
+
// TODO Maybe we should warn here if there's a length mismatch
|
|
33
|
+
times && times.length === keyframeValues.length
|
|
34
|
+
? times
|
|
35
|
+
: defaultOffset(keyframeValues), duration);
|
|
36
|
+
const mapTimeToKeyframe = interpolate(absoluteTimes, keyframeValues, {
|
|
37
|
+
ease: Array.isArray(easingFunctions)
|
|
38
|
+
? easingFunctions
|
|
39
|
+
: defaultEasing(keyframeValues, easingFunctions),
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
calculatedDuration: duration,
|
|
43
|
+
next: (t) => {
|
|
44
|
+
state.value = mapTimeToKeyframe(t);
|
|
45
|
+
state.done = t >= duration;
|
|
46
|
+
return state;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { defaultEasing, keyframes };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { warning } from '../../../utils/errors.mjs';
|
|
2
|
+
import { clamp } from '../../../utils/clamp.mjs';
|
|
3
|
+
import { secondsToMilliseconds, millisecondsToSeconds } from '../../../utils/time-conversion.mjs';
|
|
4
|
+
|
|
5
|
+
const safeMin = 0.001;
|
|
6
|
+
const minDuration = 0.01;
|
|
7
|
+
const maxDuration = 10.0;
|
|
8
|
+
const minDamping = 0.05;
|
|
9
|
+
const maxDamping = 1;
|
|
10
|
+
function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, }) {
|
|
11
|
+
let envelope;
|
|
12
|
+
let derivative;
|
|
13
|
+
warning(duration <= secondsToMilliseconds(maxDuration), "Spring duration must be 10 seconds or less");
|
|
14
|
+
let dampingRatio = 1 - bounce;
|
|
15
|
+
/**
|
|
16
|
+
* Restrict dampingRatio and duration to within acceptable ranges.
|
|
17
|
+
*/
|
|
18
|
+
dampingRatio = clamp(minDamping, maxDamping, dampingRatio);
|
|
19
|
+
duration = clamp(minDuration, maxDuration, millisecondsToSeconds(duration));
|
|
20
|
+
if (dampingRatio < 1) {
|
|
21
|
+
/**
|
|
22
|
+
* Underdamped spring
|
|
23
|
+
*/
|
|
24
|
+
envelope = (undampedFreq) => {
|
|
25
|
+
const exponentialDecay = undampedFreq * dampingRatio;
|
|
26
|
+
const delta = exponentialDecay * duration;
|
|
27
|
+
const a = exponentialDecay - velocity;
|
|
28
|
+
const b = calcAngularFreq(undampedFreq, dampingRatio);
|
|
29
|
+
const c = Math.exp(-delta);
|
|
30
|
+
return safeMin - (a / b) * c;
|
|
31
|
+
};
|
|
32
|
+
derivative = (undampedFreq) => {
|
|
33
|
+
const exponentialDecay = undampedFreq * dampingRatio;
|
|
34
|
+
const delta = exponentialDecay * duration;
|
|
35
|
+
const d = delta * velocity + velocity;
|
|
36
|
+
const e = Math.pow(dampingRatio, 2) * Math.pow(undampedFreq, 2) * duration;
|
|
37
|
+
const f = Math.exp(-delta);
|
|
38
|
+
const g = calcAngularFreq(Math.pow(undampedFreq, 2), dampingRatio);
|
|
39
|
+
const factor = -envelope(undampedFreq) + safeMin > 0 ? -1 : 1;
|
|
40
|
+
return (factor * ((d - e) * f)) / g;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
/**
|
|
45
|
+
* Critically-damped spring
|
|
46
|
+
*/
|
|
47
|
+
envelope = (undampedFreq) => {
|
|
48
|
+
const a = Math.exp(-undampedFreq * duration);
|
|
49
|
+
const b = (undampedFreq - velocity) * duration + 1;
|
|
50
|
+
return -safeMin + a * b;
|
|
51
|
+
};
|
|
52
|
+
derivative = (undampedFreq) => {
|
|
53
|
+
const a = Math.exp(-undampedFreq * duration);
|
|
54
|
+
const b = (velocity - undampedFreq) * (duration * duration);
|
|
55
|
+
return a * b;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const initialGuess = 5 / duration;
|
|
59
|
+
const undampedFreq = approximateRoot(envelope, derivative, initialGuess);
|
|
60
|
+
duration = secondsToMilliseconds(duration);
|
|
61
|
+
if (isNaN(undampedFreq)) {
|
|
62
|
+
return {
|
|
63
|
+
stiffness: 100,
|
|
64
|
+
damping: 10,
|
|
65
|
+
duration,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const stiffness = Math.pow(undampedFreq, 2) * mass;
|
|
70
|
+
return {
|
|
71
|
+
stiffness,
|
|
72
|
+
damping: dampingRatio * 2 * Math.sqrt(mass * stiffness),
|
|
73
|
+
duration,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const rootIterations = 12;
|
|
78
|
+
function approximateRoot(envelope, derivative, initialGuess) {
|
|
79
|
+
let result = initialGuess;
|
|
80
|
+
for (let i = 1; i < rootIterations; i++) {
|
|
81
|
+
result = result - envelope(result) / derivative(result);
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
function calcAngularFreq(undampedFreq, dampingRatio) {
|
|
86
|
+
return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export { calcAngularFreq, findSpring, maxDamping, maxDuration, minDamping, minDuration };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../utils/time-conversion.mjs';
|
|
2
|
+
import { calcGeneratorVelocity } from '../utils/velocity.mjs';
|
|
3
|
+
import { findSpring, calcAngularFreq } from './find.mjs';
|
|
4
|
+
|
|
5
|
+
const durationKeys = ["duration", "bounce"];
|
|
6
|
+
const physicsKeys = ["stiffness", "damping", "mass"];
|
|
7
|
+
function isSpringType(options, keys) {
|
|
8
|
+
return keys.some((key) => options[key] !== undefined);
|
|
9
|
+
}
|
|
10
|
+
function getSpringOptions(options) {
|
|
11
|
+
let springOptions = {
|
|
12
|
+
velocity: 0.0,
|
|
13
|
+
stiffness: 100,
|
|
14
|
+
damping: 10,
|
|
15
|
+
mass: 1.0,
|
|
16
|
+
isResolvedFromDuration: false,
|
|
17
|
+
...options,
|
|
18
|
+
};
|
|
19
|
+
// stiffness/damping/mass overrides duration/bounce
|
|
20
|
+
if (!isSpringType(options, physicsKeys) &&
|
|
21
|
+
isSpringType(options, durationKeys)) {
|
|
22
|
+
const derived = findSpring(options);
|
|
23
|
+
springOptions = {
|
|
24
|
+
...springOptions,
|
|
25
|
+
...derived,
|
|
26
|
+
mass: 1.0,
|
|
27
|
+
};
|
|
28
|
+
springOptions.isResolvedFromDuration = true;
|
|
29
|
+
}
|
|
30
|
+
return springOptions;
|
|
31
|
+
}
|
|
32
|
+
function spring({ keyframes, restDelta, restSpeed, ...options }) {
|
|
33
|
+
const origin = keyframes[0];
|
|
34
|
+
const target = keyframes[keyframes.length - 1];
|
|
35
|
+
/**
|
|
36
|
+
* This is the Iterator-spec return value. We ensure it's mutable rather than using a generator
|
|
37
|
+
* to reduce GC during animation.
|
|
38
|
+
*/
|
|
39
|
+
const state = { done: false, value: origin };
|
|
40
|
+
const { stiffness, damping, mass, duration, velocity, isResolvedFromDuration, } = getSpringOptions({
|
|
41
|
+
...options,
|
|
42
|
+
velocity: -millisecondsToSeconds(options.velocity || 0),
|
|
43
|
+
});
|
|
44
|
+
const initialVelocity = velocity || 0.0;
|
|
45
|
+
const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass));
|
|
46
|
+
const initialDelta = target - origin;
|
|
47
|
+
const undampedAngularFreq = millisecondsToSeconds(Math.sqrt(stiffness / mass));
|
|
48
|
+
/**
|
|
49
|
+
* If we're working on a granular scale, use smaller defaults for determining
|
|
50
|
+
* when the spring is finished.
|
|
51
|
+
*
|
|
52
|
+
* These defaults have been selected emprically based on what strikes a good
|
|
53
|
+
* ratio between feeling good and finishing as soon as changes are imperceptible.
|
|
54
|
+
*/
|
|
55
|
+
const isGranularScale = Math.abs(initialDelta) < 5;
|
|
56
|
+
restSpeed || (restSpeed = isGranularScale ? 0.01 : 2);
|
|
57
|
+
restDelta || (restDelta = isGranularScale ? 0.005 : 0.5);
|
|
58
|
+
let resolveSpring;
|
|
59
|
+
if (dampingRatio < 1) {
|
|
60
|
+
const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
|
|
61
|
+
// Underdamped spring
|
|
62
|
+
resolveSpring = (t) => {
|
|
63
|
+
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
64
|
+
return (target -
|
|
65
|
+
envelope *
|
|
66
|
+
(((initialVelocity +
|
|
67
|
+
dampingRatio * undampedAngularFreq * initialDelta) /
|
|
68
|
+
angularFreq) *
|
|
69
|
+
Math.sin(angularFreq * t) +
|
|
70
|
+
initialDelta * Math.cos(angularFreq * t)));
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
else if (dampingRatio === 1) {
|
|
74
|
+
// Critically damped spring
|
|
75
|
+
resolveSpring = (t) => target -
|
|
76
|
+
Math.exp(-undampedAngularFreq * t) *
|
|
77
|
+
(initialDelta +
|
|
78
|
+
(initialVelocity + undampedAngularFreq * initialDelta) * t);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// Overdamped spring
|
|
82
|
+
const dampedAngularFreq = undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1);
|
|
83
|
+
resolveSpring = (t) => {
|
|
84
|
+
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
85
|
+
// When performing sinh or cosh values can hit Infinity so we cap them here
|
|
86
|
+
const freqForT = Math.min(dampedAngularFreq * t, 300);
|
|
87
|
+
return (target -
|
|
88
|
+
(envelope *
|
|
89
|
+
((initialVelocity +
|
|
90
|
+
dampingRatio * undampedAngularFreq * initialDelta) *
|
|
91
|
+
Math.sinh(freqForT) +
|
|
92
|
+
dampedAngularFreq *
|
|
93
|
+
initialDelta *
|
|
94
|
+
Math.cosh(freqForT))) /
|
|
95
|
+
dampedAngularFreq);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
calculatedDuration: isResolvedFromDuration ? duration || null : null,
|
|
100
|
+
next: (t) => {
|
|
101
|
+
const current = resolveSpring(t);
|
|
102
|
+
if (!isResolvedFromDuration) {
|
|
103
|
+
let currentVelocity = 0.0;
|
|
104
|
+
/**
|
|
105
|
+
* We only need to calculate velocity for under-damped springs
|
|
106
|
+
* as over- and critically-damped springs can't overshoot, so
|
|
107
|
+
* checking only for displacement is enough.
|
|
108
|
+
*/
|
|
109
|
+
if (dampingRatio < 1) {
|
|
110
|
+
currentVelocity =
|
|
111
|
+
t === 0
|
|
112
|
+
? secondsToMilliseconds(initialVelocity)
|
|
113
|
+
: calcGeneratorVelocity(resolveSpring, t, current);
|
|
114
|
+
}
|
|
115
|
+
const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
|
|
116
|
+
const isBelowDisplacementThreshold = Math.abs(target - current) <= restDelta;
|
|
117
|
+
state.done =
|
|
118
|
+
isBelowVelocityThreshold && isBelowDisplacementThreshold;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
state.done = t >= duration;
|
|
122
|
+
}
|
|
123
|
+
state.value = state.done ? target : current;
|
|
124
|
+
return state;
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { spring };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implement a practical max duration for keyframe generation
|
|
3
|
+
* to prevent infinite loops
|
|
4
|
+
*/
|
|
5
|
+
const maxGeneratorDuration = 20000;
|
|
6
|
+
function calcGeneratorDuration(generator) {
|
|
7
|
+
let duration = 0;
|
|
8
|
+
const timeStep = 50;
|
|
9
|
+
let state = generator.next(duration);
|
|
10
|
+
while (!state.done && duration < maxGeneratorDuration) {
|
|
11
|
+
duration += timeStep;
|
|
12
|
+
state = generator.next(duration);
|
|
13
|
+
}
|
|
14
|
+
return duration >= maxGeneratorDuration ? Infinity : duration;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { calcGeneratorDuration, maxGeneratorDuration };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { velocityPerSecond } from '../../../utils/velocity-per-second.mjs';
|
|
2
|
+
|
|
3
|
+
const velocitySampleDuration = 5; // ms
|
|
4
|
+
function calcGeneratorVelocity(resolveValue, t, current) {
|
|
5
|
+
const prevT = Math.max(t - velocitySampleDuration, 0);
|
|
6
|
+
return velocityPerSecond(current - resolveValue(prevT), t - prevT);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { calcGeneratorVelocity };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { secondsToMilliseconds } from '../../utils/time-conversion.mjs';
|
|
2
|
+
import { getDefaultTransition } from '../utils/default-transitions.mjs';
|
|
3
|
+
import { getValueTransition } from '../utils/get-value-transition.mjs';
|
|
4
|
+
import { getFinalKeyframe } from '../animators/waapi/utils/get-final-keyframe.mjs';
|
|
5
|
+
import { frame } from '../../frameloop/frame.mjs';
|
|
6
|
+
import { AcceleratedAnimation } from '../animators/AcceleratedAnimation.mjs';
|
|
7
|
+
import { MainThreadAnimation } from '../animators/MainThreadAnimation.mjs';
|
|
8
|
+
import { GroupPlaybackControls } from '../GroupPlaybackControls.mjs';
|
|
9
|
+
import { isTransitionDefined } from '../utils/is-transition-defined.mjs';
|
|
10
|
+
|
|
11
|
+
const animateMotionValue = (name, value, target, transition = {}, element, isHandoff) => (onComplete) => {
|
|
12
|
+
const valueTransition = getValueTransition(transition, name) || {};
|
|
13
|
+
/**
|
|
14
|
+
* Most transition values are currently completely overwritten by value-specific
|
|
15
|
+
* transitions. In the future it'd be nicer to blend these transitions. But for now
|
|
16
|
+
* delay actually does inherit from the root transition if not value-specific.
|
|
17
|
+
*/
|
|
18
|
+
const delay = valueTransition.delay || transition.delay || 0;
|
|
19
|
+
/**
|
|
20
|
+
* Elapsed isn't a public transition option but can be passed through from
|
|
21
|
+
* optimized appear effects in milliseconds.
|
|
22
|
+
*/
|
|
23
|
+
let { elapsed = 0 } = transition;
|
|
24
|
+
elapsed = elapsed - secondsToMilliseconds(delay);
|
|
25
|
+
let options = {
|
|
26
|
+
keyframes: Array.isArray(target) ? target : [null, target],
|
|
27
|
+
ease: "easeOut",
|
|
28
|
+
velocity: value.getVelocity(),
|
|
29
|
+
...valueTransition,
|
|
30
|
+
delay: -elapsed,
|
|
31
|
+
onUpdate: (v) => {
|
|
32
|
+
value.set(v);
|
|
33
|
+
valueTransition.onUpdate && valueTransition.onUpdate(v);
|
|
34
|
+
},
|
|
35
|
+
onComplete: () => {
|
|
36
|
+
onComplete();
|
|
37
|
+
valueTransition.onComplete && valueTransition.onComplete();
|
|
38
|
+
},
|
|
39
|
+
name,
|
|
40
|
+
motionValue: value,
|
|
41
|
+
element: isHandoff ? undefined : element,
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* If there's no transition defined for this value, we can generate
|
|
45
|
+
* unqiue transition settings for this value.
|
|
46
|
+
*/
|
|
47
|
+
if (!isTransitionDefined(valueTransition)) {
|
|
48
|
+
options = {
|
|
49
|
+
...options,
|
|
50
|
+
...getDefaultTransition(name, options),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Both WAAPI and our internal animation functions use durations
|
|
55
|
+
* as defined by milliseconds, while our external API defines them
|
|
56
|
+
* as seconds.
|
|
57
|
+
*/
|
|
58
|
+
if (options.duration) {
|
|
59
|
+
options.duration = secondsToMilliseconds(options.duration);
|
|
60
|
+
}
|
|
61
|
+
if (options.repeatDelay) {
|
|
62
|
+
options.repeatDelay = secondsToMilliseconds(options.repeatDelay);
|
|
63
|
+
}
|
|
64
|
+
if (options.from !== undefined) {
|
|
65
|
+
options.keyframes[0] = options.from;
|
|
66
|
+
}
|
|
67
|
+
let shouldSkip = false;
|
|
68
|
+
if (options.type === false ||
|
|
69
|
+
(options.duration === 0 && !options.repeatDelay)) {
|
|
70
|
+
options.duration = 0;
|
|
71
|
+
if (options.delay === 0) {
|
|
72
|
+
shouldSkip = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* If we can or must skip creating the animation, and apply only
|
|
77
|
+
* the final keyframe, do so. We also check once keyframes are resolved but
|
|
78
|
+
* this early check prevents the need to create an animation at all.
|
|
79
|
+
*/
|
|
80
|
+
if (shouldSkip && !isHandoff && value.get() !== undefined) {
|
|
81
|
+
const finalKeyframe = getFinalKeyframe(options.keyframes, valueTransition);
|
|
82
|
+
if (finalKeyframe !== undefined) {
|
|
83
|
+
frame.update(() => {
|
|
84
|
+
options.onUpdate(finalKeyframe);
|
|
85
|
+
options.onComplete();
|
|
86
|
+
});
|
|
87
|
+
// We still want to return some animation controls here rather
|
|
88
|
+
// than returning undefined
|
|
89
|
+
return new GroupPlaybackControls([]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Animate via WAAPI if possible. If this is a handoff animation, the optimised animation will be running via
|
|
94
|
+
* WAAPI. Therefore, this animation must be JS to ensure it runs "under" the
|
|
95
|
+
* optimised animation.
|
|
96
|
+
*/
|
|
97
|
+
if (!isHandoff && AcceleratedAnimation.supports(options)) {
|
|
98
|
+
return new AcceleratedAnimation(options);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return new MainThreadAnimation(options);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export { animateMotionValue };
|