motion 12.18.1 → 12.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/mini.js +7 -1063
- package/dist/es/debug.mjs +1 -0
- package/dist/es/index.mjs +1 -0
- package/dist/es/mini.mjs +1 -0
- package/dist/es/react-client.mjs +2 -0
- package/dist/es/react-m.mjs +2 -0
- package/dist/es/react-mini.mjs +2 -0
- package/dist/es/react.mjs +2 -0
- package/dist/motion.dev.js +2 -2
- package/dist/motion.js +1 -1
- package/mini/package.json +1 -1
- package/package.json +11 -11
- package/react/package.json +1 -1
- package/react-client/package.json +1 -1
- package/react-m/package.json +1 -1
- package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +0 -34
- package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +0 -19
- package/dist/es/framer-motion/dist/es/animation/animate/sequence.mjs +0 -14
- package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +0 -11
- package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +0 -52
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +0 -112
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-sequence.mjs +0 -13
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +0 -12
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/get-final-keyframe.mjs +0 -12
- package/dist/es/framer-motion/dist/es/animation/hooks/animation-controls.mjs +0 -80
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animate-style.mjs +0 -17
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animate.mjs +0 -17
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animated-state.mjs +0 -64
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animation.mjs +0 -41
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +0 -102
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +0 -85
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-variant.mjs +0 -65
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element.mjs +0 -26
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/data-id.mjs +0 -6
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/get-appear-id.mjs +0 -7
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/handoff.mjs +0 -38
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +0 -171
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/store-id.mjs +0 -8
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/store.mjs +0 -4
- package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +0 -256
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-repeat-duration.mjs +0 -5
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-time.mjs +0 -23
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/edit.mjs +0 -31
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/normalize-times.mjs +0 -13
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/sort.mjs +0 -14
- package/dist/es/framer-motion/dist/es/animation/utils/create-visual-element.mjs +0 -45
- package/dist/es/framer-motion/dist/es/animation/utils/default-transitions.mjs +0 -40
- package/dist/es/framer-motion/dist/es/animation/utils/is-animation-controls.mjs +0 -7
- package/dist/es/framer-motion/dist/es/animation/utils/is-dom-keyframes.mjs +0 -5
- package/dist/es/framer-motion/dist/es/animation/utils/is-keyframes-target.mjs +0 -5
- package/dist/es/framer-motion/dist/es/animation/utils/is-transition-defined.mjs +0 -10
- package/dist/es/framer-motion/dist/es/animation/utils/stagger.mjs +0 -26
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs +0 -87
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs +0 -64
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +0 -166
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence-data.mjs +0 -9
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs +0 -70
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/utils.mjs +0 -14
- package/dist/es/framer-motion/dist/es/components/AnimateSharedLayout.mjs +0 -15
- package/dist/es/framer-motion/dist/es/components/LayoutGroup/index.mjs +0 -32
- package/dist/es/framer-motion/dist/es/components/LazyMotion/index.mjs +0 -68
- package/dist/es/framer-motion/dist/es/components/MotionConfig/index.mjs +0 -48
- package/dist/es/framer-motion/dist/es/components/Reorder/Group.mjs +0 -53
- package/dist/es/framer-motion/dist/es/components/Reorder/Item.mjs +0 -34
- package/dist/es/framer-motion/dist/es/components/Reorder/namespace.mjs +0 -2
- package/dist/es/framer-motion/dist/es/components/Reorder/utils/check-reorder.mjs +0 -24
- package/dist/es/framer-motion/dist/es/context/DeprecatedLayoutGroupContext.mjs +0 -10
- package/dist/es/framer-motion/dist/es/context/LayoutGroupContext.mjs +0 -6
- package/dist/es/framer-motion/dist/es/context/LazyContext.mjs +0 -6
- package/dist/es/framer-motion/dist/es/context/MotionConfigContext.mjs +0 -13
- package/dist/es/framer-motion/dist/es/context/MotionContext/create.mjs +0 -13
- package/dist/es/framer-motion/dist/es/context/MotionContext/index.mjs +0 -6
- package/dist/es/framer-motion/dist/es/context/MotionContext/utils.mjs +0 -17
- package/dist/es/framer-motion/dist/es/context/PresenceContext.mjs +0 -10
- package/dist/es/framer-motion/dist/es/context/ReorderContext.mjs +0 -6
- package/dist/es/framer-motion/dist/es/context/SwitchLayoutGroupContext.mjs +0 -9
- package/dist/es/framer-motion/dist/es/events/add-dom-event.mjs +0 -6
- package/dist/es/framer-motion/dist/es/events/add-pointer-event.mjs +0 -8
- package/dist/es/framer-motion/dist/es/events/event-info.mjs +0 -15
- package/dist/es/framer-motion/dist/es/events/use-dom-event.mjs +0 -34
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +0 -479
- package/dist/es/framer-motion/dist/es/gestures/drag/index.mjs +0 -27
- package/dist/es/framer-motion/dist/es/gestures/drag/use-drag-controls.mjs +0 -88
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +0 -129
- package/dist/es/framer-motion/dist/es/gestures/focus.mjs +0 -41
- package/dist/es/framer-motion/dist/es/gestures/hover.mjs +0 -30
- package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +0 -156
- package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +0 -50
- package/dist/es/framer-motion/dist/es/gestures/press.mjs +0 -33
- package/dist/es/framer-motion/dist/es/motion/features/Feature.mjs +0 -9
- package/dist/es/framer-motion/dist/es/motion/features/animation/exit.mjs +0 -36
- package/dist/es/framer-motion/dist/es/motion/features/animation/index.mjs +0 -40
- package/dist/es/framer-motion/dist/es/motion/features/animations.mjs +0 -13
- package/dist/es/framer-motion/dist/es/motion/features/definitions.mjs +0 -28
- package/dist/es/framer-motion/dist/es/motion/features/drag.mjs +0 -17
- package/dist/es/framer-motion/dist/es/motion/features/gestures.mjs +0 -21
- package/dist/es/framer-motion/dist/es/motion/features/layout/MeasureLayout.mjs +0 -135
- package/dist/es/framer-motion/dist/es/motion/features/layout.mjs +0 -11
- package/dist/es/framer-motion/dist/es/motion/features/load-features.mjs +0 -12
- package/dist/es/framer-motion/dist/es/motion/features/viewport/index.mjs +0 -72
- package/dist/es/framer-motion/dist/es/motion/features/viewport/observers.mjs +0 -49
- package/dist/es/framer-motion/dist/es/motion/index.mjs +0 -101
- package/dist/es/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +0 -11
- package/dist/es/framer-motion/dist/es/motion/utils/is-motion-component.mjs +0 -12
- package/dist/es/framer-motion/dist/es/motion/utils/symbol.mjs +0 -3
- package/dist/es/framer-motion/dist/es/motion/utils/unwrap-motion-component.mjs +0 -17
- package/dist/es/framer-motion/dist/es/motion/utils/use-motion-ref.mjs +0 -38
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +0 -133
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-state.mjs +0 -79
- package/dist/es/framer-motion/dist/es/motion/utils/valid-prop.mjs +0 -57
- package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +0 -91
- package/dist/es/framer-motion/dist/es/projection/geometry/conversion.mjs +0 -33
- package/dist/es/framer-motion/dist/es/projection/geometry/copy.mjs +0 -31
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-apply.mjs +0 -119
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-calc.mjs +0 -52
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-remove.mjs +0 -54
- package/dist/es/framer-motion/dist/es/projection/geometry/models.mjs +0 -17
- package/dist/es/framer-motion/dist/es/projection/geometry/utils.mjs +0 -31
- package/dist/es/framer-motion/dist/es/projection/node/DocumentProjectionNode.mjs +0 -13
- package/dist/es/framer-motion/dist/es/projection/node/HTMLProjectionNode.mjs +0 -27
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +0 -1605
- package/dist/es/framer-motion/dist/es/projection/node/group.mjs +0 -24
- package/dist/es/framer-motion/dist/es/projection/node/state.mjs +0 -19
- package/dist/es/framer-motion/dist/es/projection/shared/stack.mjs +0 -112
- package/dist/es/framer-motion/dist/es/projection/styles/scale-border-radius.mjs +0 -41
- package/dist/es/framer-motion/dist/es/projection/styles/scale-box-shadow.mjs +0 -35
- package/dist/es/framer-motion/dist/es/projection/styles/scale-correction.mjs +0 -13
- package/dist/es/framer-motion/dist/es/projection/styles/transform.mjs +0 -49
- package/dist/es/framer-motion/dist/es/projection/use-instant-layout-transition.mjs +0 -14
- package/dist/es/framer-motion/dist/es/projection/use-reset-projection.mjs +0 -14
- package/dist/es/framer-motion/dist/es/projection/utils/each-axis.mjs +0 -5
- package/dist/es/framer-motion/dist/es/projection/utils/has-transform.mjs +0 -26
- package/dist/es/framer-motion/dist/es/projection/utils/measure.mjs +0 -17
- package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +0 -478
- package/dist/es/framer-motion/dist/es/render/components/create-factory.mjs +0 -23
- package/dist/es/framer-motion/dist/es/render/components/create-proxy.mjs +0 -38
- package/dist/es/framer-motion/dist/es/render/components/m/create.mjs +0 -6
- package/dist/es/framer-motion/dist/es/render/components/m/elements.mjs +0 -227
- package/dist/es/framer-motion/dist/es/render/components/m/proxy.mjs +0 -6
- package/dist/es/framer-motion/dist/es/render/components/motion/create.mjs +0 -15
- package/dist/es/framer-motion/dist/es/render/components/motion/elements.mjs +0 -194
- package/dist/es/framer-motion/dist/es/render/components/motion/proxy.mjs +0 -6
- package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +0 -43
- package/dist/es/framer-motion/dist/es/render/dom/create-visual-element.mjs +0 -14
- package/dist/es/framer-motion/dist/es/render/dom/features-animation.mjs +0 -14
- package/dist/es/framer-motion/dist/es/render/dom/features-max.mjs +0 -14
- package/dist/es/framer-motion/dist/es/render/dom/features-min.mjs +0 -12
- package/dist/es/framer-motion/dist/es/render/dom/scroll/attach-animation.mjs +0 -17
- package/dist/es/framer-motion/dist/es/render/dom/scroll/attach-function.mjs +0 -23
- package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +0 -14
- package/dist/es/framer-motion/dist/es/render/dom/scroll/info.mjs +0 -56
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/edge.mjs +0 -45
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +0 -60
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/inset.mjs +0 -47
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/offset.mjs +0 -35
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/presets.mjs +0 -20
- package/dist/es/framer-motion/dist/es/render/dom/scroll/on-scroll-handler.mjs +0 -48
- package/dist/es/framer-motion/dist/es/render/dom/scroll/track.mjs +0 -81
- package/dist/es/framer-motion/dist/es/render/dom/scroll/utils/get-timeline.mjs +0 -30
- package/dist/es/framer-motion/dist/es/render/dom/use-render.mjs +0 -33
- package/dist/es/framer-motion/dist/es/render/dom/utils/camel-to-dash.mjs +0 -6
- package/dist/es/framer-motion/dist/es/render/dom/utils/filter-props.mjs +0 -59
- package/dist/es/framer-motion/dist/es/render/dom/utils/is-svg-component.mjs +0 -30
- package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +0 -43
- package/dist/es/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +0 -44
- package/dist/es/framer-motion/dist/es/render/html/config-motion.mjs +0 -12
- package/dist/es/framer-motion/dist/es/render/html/use-props.mjs +0 -57
- package/dist/es/framer-motion/dist/es/render/html/utils/build-styles.mjs +0 -65
- package/dist/es/framer-motion/dist/es/render/html/utils/build-transform.mjs +0 -62
- package/dist/es/framer-motion/dist/es/render/html/utils/create-render-state.mjs +0 -8
- package/dist/es/framer-motion/dist/es/render/html/utils/render.mjs +0 -9
- package/dist/es/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +0 -19
- package/dist/es/framer-motion/dist/es/render/object/ObjectVisualElement.mjs +0 -41
- package/dist/es/framer-motion/dist/es/render/store.mjs +0 -3
- package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +0 -45
- package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +0 -12
- package/dist/es/framer-motion/dist/es/render/svg/lowercase-elements.mjs +0 -33
- package/dist/es/framer-motion/dist/es/render/svg/use-props.mjs +0 -24
- package/dist/es/framer-motion/dist/es/render/svg/utils/build-attrs.mjs +0 -57
- package/dist/es/framer-motion/dist/es/render/svg/utils/camel-case-attrs.mjs +0 -30
- package/dist/es/framer-motion/dist/es/render/svg/utils/create-render-state.mjs +0 -8
- package/dist/es/framer-motion/dist/es/render/svg/utils/is-svg-tag.mjs +0 -3
- package/dist/es/framer-motion/dist/es/render/svg/utils/path.mjs +0 -32
- package/dist/es/framer-motion/dist/es/render/svg/utils/render.mjs +0 -12
- package/dist/es/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +0 -19
- package/dist/es/framer-motion/dist/es/render/utils/animation-state.mjs +0 -342
- package/dist/es/framer-motion/dist/es/render/utils/compare-by-depth.mjs +0 -3
- package/dist/es/framer-motion/dist/es/render/utils/flat-tree.mjs +0 -24
- package/dist/es/framer-motion/dist/es/render/utils/get-variant-context.mjs +0 -28
- package/dist/es/framer-motion/dist/es/render/utils/is-controlling-variants.mjs +0 -13
- package/dist/es/framer-motion/dist/es/render/utils/is-variant-label.mjs +0 -8
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +0 -51
- package/dist/es/framer-motion/dist/es/render/utils/resolve-dynamic-variants.mjs +0 -8
- package/dist/es/framer-motion/dist/es/render/utils/resolve-variants.mjs +0 -36
- package/dist/es/framer-motion/dist/es/render/utils/setters.mjs +0 -31
- package/dist/es/framer-motion/dist/es/render/utils/variant-props.mjs +0 -12
- package/dist/es/framer-motion/dist/es/utils/delay.mjs +0 -24
- package/dist/es/framer-motion/dist/es/utils/distance.mjs +0 -9
- package/dist/es/framer-motion/dist/es/utils/get-context-window.mjs +0 -6
- package/dist/es/framer-motion/dist/es/utils/is-browser.mjs +0 -3
- package/dist/es/framer-motion/dist/es/utils/is-ref-object.mjs +0 -7
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/index.mjs +0 -19
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/state.mjs +0 -5
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion-config.mjs +0 -19
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.mjs +0 -47
- package/dist/es/framer-motion/dist/es/utils/shallow-compare.mjs +0 -14
- package/dist/es/framer-motion/dist/es/utils/use-animation-frame.mjs +0 -21
- package/dist/es/framer-motion/dist/es/utils/use-constant.mjs +0 -18
- package/dist/es/framer-motion/dist/es/utils/use-cycle.mjs +0 -47
- package/dist/es/framer-motion/dist/es/utils/use-force-update.mjs +0 -19
- package/dist/es/framer-motion/dist/es/utils/use-in-view.mjs +0 -23
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition.mjs +0 -41
- package/dist/es/framer-motion/dist/es/utils/use-is-mounted.mjs +0 -15
- package/dist/es/framer-motion/dist/es/utils/use-isomorphic-effect.mjs +0 -6
- package/dist/es/framer-motion/dist/es/utils/use-motion-value-event.mjs +0 -13
- package/dist/es/framer-motion/dist/es/utils/use-unmount-effect.mjs +0 -7
- package/dist/es/framer-motion/dist/es/value/scroll/use-element-scroll.mjs +0 -14
- package/dist/es/framer-motion/dist/es/value/scroll/use-viewport-scroll.mjs +0 -14
- package/dist/es/framer-motion/dist/es/value/use-combine-values.mjs +0 -37
- package/dist/es/framer-motion/dist/es/value/use-computed.mjs +0 -19
- package/dist/es/framer-motion/dist/es/value/use-inverted-scale.mjs +0 -52
- package/dist/es/framer-motion/dist/es/value/use-motion-template.mjs +0 -45
- package/dist/es/framer-motion/dist/es/value/use-motion-value.mjs +0 -38
- package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +0 -39
- package/dist/es/framer-motion/dist/es/value/use-spring.mjs +0 -22
- package/dist/es/framer-motion/dist/es/value/use-time.mjs +0 -10
- package/dist/es/framer-motion/dist/es/value/use-transform.mjs +0 -29
- package/dist/es/framer-motion/dist/es/value/use-velocity.mjs +0 -35
- package/dist/es/framer-motion/dist/es/value/use-will-change/WillChangeMotionValue.mjs +0 -21
- package/dist/es/framer-motion/dist/es/value/use-will-change/add-will-change.mjs +0 -20
- package/dist/es/framer-motion/dist/es/value/use-will-change/index.mjs +0 -8
- package/dist/es/framer-motion/dist/es/value/use-will-change/is.mjs +0 -7
- package/dist/es/framer-motion/dist/es/value/utils/resolve-motion-value.mjs +0 -12
- package/dist/es/motion/lib/debug.mjs +0 -1
- package/dist/es/motion/lib/index.mjs +0 -131
- package/dist/es/motion/lib/mini.mjs +0 -2
- package/dist/es/motion/lib/react-client.mjs +0 -3
- package/dist/es/motion/lib/react-m.mjs +0 -3
- package/dist/es/motion/lib/react-mini.mjs +0 -2
- package/dist/es/motion/lib/react.mjs +0 -204
- package/dist/es/motion-dom/dist/es/animation/AsyncMotionValueAnimation.mjs +0 -175
- package/dist/es/motion-dom/dist/es/animation/GroupAnimation.mjs +0 -72
- package/dist/es/motion-dom/dist/es/animation/GroupAnimationWithThen.mjs +0 -9
- package/dist/es/motion-dom/dist/es/animation/JSAnimation.mjs +0 -348
- package/dist/es/motion-dom/dist/es/animation/NativeAnimation.mjs +0 -158
- package/dist/es/motion-dom/dist/es/animation/NativeAnimationExtended.mjs +0 -65
- package/dist/es/motion-dom/dist/es/animation/NativeAnimationWrapper.mjs +0 -14
- package/dist/es/motion-dom/dist/es/animation/drivers/frame.mjs +0 -17
- package/dist/es/motion-dom/dist/es/animation/generators/inertia.mjs +0 -87
- package/dist/es/motion-dom/dist/es/animation/generators/keyframes.mjs +0 -51
- package/dist/es/motion-dom/dist/es/animation/generators/spring/defaults.mjs +0 -27
- package/dist/es/motion-dom/dist/es/animation/generators/spring/find.mjs +0 -86
- package/dist/es/motion-dom/dist/es/animation/generators/spring/index.mjs +0 -176
- package/dist/es/motion-dom/dist/es/animation/generators/utils/calc-duration.mjs +0 -17
- package/dist/es/motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs +0 -19
- package/dist/es/motion-dom/dist/es/animation/generators/utils/is-generator.mjs +0 -5
- package/dist/es/motion-dom/dist/es/animation/generators/utils/velocity.mjs +0 -9
- package/dist/es/motion-dom/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +0 -131
- package/dist/es/motion-dom/dist/es/animation/keyframes/KeyframesResolver.mjs +0 -147
- package/dist/es/motion-dom/dist/es/animation/keyframes/get-final.mjs +0 -11
- package/dist/es/motion-dom/dist/es/animation/keyframes/offsets/default.mjs +0 -9
- package/dist/es/motion-dom/dist/es/animation/keyframes/offsets/fill.mjs +0 -12
- package/dist/es/motion-dom/dist/es/animation/keyframes/offsets/time.mjs +0 -5
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/apply-px-defaults.mjs +0 -11
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/fill-wildcards.mjs +0 -7
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/is-none.mjs +0 -15
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/make-none-animatable.mjs +0 -30
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/unit-conversion.mjs +0 -36
- package/dist/es/motion-dom/dist/es/animation/utils/WithPromise.mjs +0 -26
- package/dist/es/motion-dom/dist/es/animation/utils/active-animations.mjs +0 -9
- package/dist/es/motion-dom/dist/es/animation/utils/can-animate.mjs +0 -42
- package/dist/es/motion-dom/dist/es/animation/utils/css-variables-conversion.mjs +0 -42
- package/dist/es/motion-dom/dist/es/animation/utils/get-value-transition.mjs +0 -7
- package/dist/es/motion-dom/dist/es/animation/utils/is-animatable.mjs +0 -30
- package/dist/es/motion-dom/dist/es/animation/utils/is-css-variable.mjs +0 -15
- package/dist/es/motion-dom/dist/es/animation/utils/replace-transition-type.mjs +0 -18
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/cubic-bezier.mjs +0 -3
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/is-supported.mjs +0 -14
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/map-easing.mjs +0 -28
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/supported.mjs +0 -15
- package/dist/es/motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs +0 -39
- package/dist/es/motion-dom/dist/es/animation/waapi/supports/partial-keyframes.mjs +0 -13
- package/dist/es/motion-dom/dist/es/animation/waapi/supports/waapi.mjs +0 -37
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/accelerated-values.mjs +0 -14
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/apply-generator.mjs +0 -15
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/linear.mjs +0 -12
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/px-values.mjs +0 -39
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/unsupported-easing.mjs +0 -20
- package/dist/es/motion-dom/dist/es/effects/MotionValueState.mjs +0 -47
- package/dist/es/motion-dom/dist/es/effects/attr/index.mjs +0 -41
- package/dist/es/motion-dom/dist/es/effects/prop/index.mjs +0 -9
- package/dist/es/motion-dom/dist/es/effects/style/index.mjs +0 -52
- package/dist/es/motion-dom/dist/es/effects/style/transform.mjs +0 -38
- package/dist/es/motion-dom/dist/es/effects/svg/index.mjs +0 -41
- package/dist/es/motion-dom/dist/es/effects/utils/create-dom-effect.mjs +0 -18
- package/dist/es/motion-dom/dist/es/effects/utils/create-effect.mjs +0 -21
- package/dist/es/motion-dom/dist/es/frameloop/batcher.mjs +0 -71
- package/dist/es/motion-dom/dist/es/frameloop/frame.mjs +0 -6
- package/dist/es/motion-dom/dist/es/frameloop/index-legacy.mjs +0 -20
- package/dist/es/motion-dom/dist/es/frameloop/microtask.mjs +0 -6
- package/dist/es/motion-dom/dist/es/frameloop/order.mjs +0 -12
- package/dist/es/motion-dom/dist/es/frameloop/render-step.mjs +0 -92
- package/dist/es/motion-dom/dist/es/frameloop/sync-time.mjs +0 -31
- package/dist/es/motion-dom/dist/es/gestures/drag/state/is-active.mjs +0 -9
- package/dist/es/motion-dom/dist/es/gestures/drag/state/set-active.mjs +0 -28
- package/dist/es/motion-dom/dist/es/gestures/hover.mjs +0 -37
- package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +0 -83
- package/dist/es/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.mjs +0 -13
- package/dist/es/motion-dom/dist/es/gestures/press/utils/keyboard.mjs +0 -38
- package/dist/es/motion-dom/dist/es/gestures/press/utils/state.mjs +0 -3
- package/dist/es/motion-dom/dist/es/gestures/utils/is-node-or-child.mjs +0 -20
- package/dist/es/motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs +0 -18
- package/dist/es/motion-dom/dist/es/gestures/utils/setup.mjs +0 -15
- package/dist/es/motion-dom/dist/es/render/dom/is-css-var.mjs +0 -3
- package/dist/es/motion-dom/dist/es/render/dom/parse-transform.mjs +0 -83
- package/dist/es/motion-dom/dist/es/render/dom/style-computed.mjs +0 -10
- package/dist/es/motion-dom/dist/es/render/dom/style-set.mjs +0 -9
- package/dist/es/motion-dom/dist/es/render/dom/utils/camel-to-dash.mjs +0 -5
- package/dist/es/motion-dom/dist/es/render/utils/keys-position.mjs +0 -13
- package/dist/es/motion-dom/dist/es/render/utils/keys-transform.mjs +0 -28
- package/dist/es/motion-dom/dist/es/resize/handle-element.mjs +0 -63
- package/dist/es/motion-dom/dist/es/resize/handle-window.mjs +0 -31
- package/dist/es/motion-dom/dist/es/resize/index.mjs +0 -8
- package/dist/es/motion-dom/dist/es/scroll/observe.mjs +0 -18
- package/dist/es/motion-dom/dist/es/stats/animation-count.mjs +0 -7
- package/dist/es/motion-dom/dist/es/stats/buffer.mjs +0 -6
- package/dist/es/motion-dom/dist/es/stats/index.mjs +0 -117
- package/dist/es/motion-dom/dist/es/utils/interpolate.mjs +0 -79
- package/dist/es/motion-dom/dist/es/utils/is-html-element.mjs +0 -11
- package/dist/es/motion-dom/dist/es/utils/is-svg-element.mjs +0 -11
- package/dist/es/motion-dom/dist/es/utils/is-svg-svg-element.mjs +0 -11
- package/dist/es/motion-dom/dist/es/utils/mix/color.mjs +0 -47
- package/dist/es/motion-dom/dist/es/utils/mix/complex.mjs +0 -93
- package/dist/es/motion-dom/dist/es/utils/mix/immediate.mjs +0 -5
- package/dist/es/motion-dom/dist/es/utils/mix/index.mjs +0 -14
- package/dist/es/motion-dom/dist/es/utils/mix/number.mjs +0 -26
- package/dist/es/motion-dom/dist/es/utils/mix/visibility.mjs +0 -16
- package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +0 -17
- package/dist/es/motion-dom/dist/es/utils/supports/flags.mjs +0 -7
- package/dist/es/motion-dom/dist/es/utils/supports/linear-easing.mjs +0 -15
- package/dist/es/motion-dom/dist/es/utils/supports/memo.mjs +0 -9
- package/dist/es/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +0 -5
- package/dist/es/motion-dom/dist/es/utils/transform.mjs +0 -14
- package/dist/es/motion-dom/dist/es/value/index.mjs +0 -329
- package/dist/es/motion-dom/dist/es/value/map-value.mjs +0 -46
- package/dist/es/motion-dom/dist/es/value/spring-value.mjs +0 -72
- package/dist/es/motion-dom/dist/es/value/subscribe-value.mjs +0 -13
- package/dist/es/motion-dom/dist/es/value/transform-value.mjs +0 -35
- package/dist/es/motion-dom/dist/es/value/types/auto.mjs +0 -9
- package/dist/es/motion-dom/dist/es/value/types/color/hex.mjs +0 -40
- package/dist/es/motion-dom/dist/es/value/types/color/hsla-to-rgba.mjs +0 -42
- package/dist/es/motion-dom/dist/es/value/types/color/hsla.mjs +0 -22
- package/dist/es/motion-dom/dist/es/value/types/color/index.mjs +0 -32
- package/dist/es/motion-dom/dist/es/value/types/color/rgba.mjs +0 -25
- package/dist/es/motion-dom/dist/es/value/types/color/utils.mjs +0 -29
- package/dist/es/motion-dom/dist/es/value/types/complex/filter.mjs +0 -30
- package/dist/es/motion-dom/dist/es/value/types/complex/index.mjs +0 -91
- package/dist/es/motion-dom/dist/es/value/types/dimensions.mjs +0 -15
- package/dist/es/motion-dom/dist/es/value/types/int.mjs +0 -8
- package/dist/es/motion-dom/dist/es/value/types/maps/defaults.mjs +0 -30
- package/dist/es/motion-dom/dist/es/value/types/maps/number.mjs +0 -50
- package/dist/es/motion-dom/dist/es/value/types/maps/transform.mjs +0 -31
- package/dist/es/motion-dom/dist/es/value/types/numbers/index.mjs +0 -17
- package/dist/es/motion-dom/dist/es/value/types/numbers/units.mjs +0 -18
- package/dist/es/motion-dom/dist/es/value/types/test.mjs +0 -6
- package/dist/es/motion-dom/dist/es/value/types/utils/animatable-none.mjs +0 -15
- package/dist/es/motion-dom/dist/es/value/types/utils/color-regex.mjs +0 -3
- package/dist/es/motion-dom/dist/es/value/types/utils/find.mjs +0 -15
- package/dist/es/motion-dom/dist/es/value/types/utils/float-regex.mjs +0 -3
- package/dist/es/motion-dom/dist/es/value/types/utils/get-as-type.mjs +0 -10
- package/dist/es/motion-dom/dist/es/value/types/utils/is-nullish.mjs +0 -5
- package/dist/es/motion-dom/dist/es/value/types/utils/sanitize.mjs +0 -5
- package/dist/es/motion-dom/dist/es/value/types/utils/single-color-regex.mjs +0 -3
- package/dist/es/motion-dom/dist/es/value/utils/is-motion-value.mjs +0 -3
- package/dist/es/motion-dom/dist/es/view/index.mjs +0 -64
- package/dist/es/motion-dom/dist/es/view/queue.mjs +0 -52
- package/dist/es/motion-dom/dist/es/view/start.mjs +0 -155
- package/dist/es/motion-dom/dist/es/view/utils/choose-layer-type.mjs +0 -11
- package/dist/es/motion-dom/dist/es/view/utils/css.mjs +0 -32
- package/dist/es/motion-dom/dist/es/view/utils/get-layer-name.mjs +0 -8
- package/dist/es/motion-dom/dist/es/view/utils/get-view-animations.mjs +0 -12
- package/dist/es/motion-dom/dist/es/view/utils/has-target.mjs +0 -5
- package/dist/es/motion-utils/dist/es/array.mjs +0 -21
- package/dist/es/motion-utils/dist/es/clamp.mjs +0 -9
- package/dist/es/motion-utils/dist/es/easing/anticipate.mjs +0 -5
- package/dist/es/motion-utils/dist/es/easing/back.mjs +0 -9
- package/dist/es/motion-utils/dist/es/easing/circ.mjs +0 -8
- package/dist/es/motion-utils/dist/es/easing/cubic-bezier.mjs +0 -51
- package/dist/es/motion-utils/dist/es/easing/ease.mjs +0 -7
- package/dist/es/motion-utils/dist/es/easing/modifiers/mirror.mjs +0 -5
- package/dist/es/motion-utils/dist/es/easing/modifiers/reverse.mjs +0 -5
- package/dist/es/motion-utils/dist/es/easing/steps.mjs +0 -15
- package/dist/es/motion-utils/dist/es/easing/utils/get-easing-for-segment.mjs +0 -8
- package/dist/es/motion-utils/dist/es/easing/utils/is-bezier-definition.mjs +0 -3
- package/dist/es/motion-utils/dist/es/easing/utils/is-easing-array.mjs +0 -5
- package/dist/es/motion-utils/dist/es/easing/utils/map.mjs +0 -41
- package/dist/es/motion-utils/dist/es/errors.mjs +0 -16
- package/dist/es/motion-utils/dist/es/global-config.mjs +0 -3
- package/dist/es/motion-utils/dist/es/is-numerical-string.mjs +0 -6
- package/dist/es/motion-utils/dist/es/is-object.mjs +0 -5
- package/dist/es/motion-utils/dist/es/is-zero-value-string.mjs +0 -6
- package/dist/es/motion-utils/dist/es/memo.mjs +0 -11
- package/dist/es/motion-utils/dist/es/noop.mjs +0 -4
- package/dist/es/motion-utils/dist/es/pipe.mjs +0 -11
- package/dist/es/motion-utils/dist/es/progress.mjs +0 -19
- package/dist/es/motion-utils/dist/es/subscription-manager.mjs +0 -40
- package/dist/es/motion-utils/dist/es/time-conversion.mjs +0 -12
- package/dist/es/motion-utils/dist/es/velocity-per-second.mjs +0 -11
- package/dist/es/motion-utils/dist/es/warn-once.mjs +0 -14
- package/dist/es/motion-utils/dist/es/wrap.mjs +0 -6
package/dist/cjs/mini.js
CHANGED
|
@@ -2,1069 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
const index = arr.indexOf(item);
|
|
7
|
-
if (index > -1)
|
|
8
|
-
arr.splice(index, 1);
|
|
9
|
-
}
|
|
5
|
+
var mini = require('framer-motion/dom/mini');
|
|
10
6
|
|
|
11
|
-
let invariant = () => { };
|
|
12
|
-
if (process.env.NODE_ENV !== "production") {
|
|
13
|
-
invariant = (check, message) => {
|
|
14
|
-
if (!check) {
|
|
15
|
-
throw new Error(message);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
7
|
|
|
20
|
-
/*#__NO_SIDE_EFFECTS__*/
|
|
21
|
-
function memo(callback) {
|
|
22
|
-
let result;
|
|
23
|
-
return () => {
|
|
24
|
-
if (result === undefined)
|
|
25
|
-
result = callback();
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
8
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Given a lower limit and an upper limit, we return the progress
|
|
37
|
-
(expressed as a number 0-1) represented by the given value, and
|
|
38
|
-
limit that progress to within 0-1.
|
|
39
|
-
|
|
40
|
-
@param [number]: Lower limit
|
|
41
|
-
@param [number]: Upper limit
|
|
42
|
-
@param [number]: Value to find progress within given range
|
|
43
|
-
@return [number]: Progress of value within range as expressed 0-1
|
|
44
|
-
*/
|
|
45
|
-
/*#__NO_SIDE_EFFECTS__*/
|
|
46
|
-
const progress = (from, to, value) => {
|
|
47
|
-
const toFromDifference = to - from;
|
|
48
|
-
return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Converts seconds to milliseconds
|
|
53
|
-
*
|
|
54
|
-
* @param seconds - Time in seconds.
|
|
55
|
-
* @return milliseconds - Converted time in milliseconds.
|
|
56
|
-
*/
|
|
57
|
-
/*#__NO_SIDE_EFFECTS__*/
|
|
58
|
-
const secondsToMilliseconds = (seconds) => seconds * 1000;
|
|
59
|
-
/*#__NO_SIDE_EFFECTS__*/
|
|
60
|
-
const millisecondsToSeconds = (milliseconds) => milliseconds / 1000;
|
|
61
|
-
|
|
62
|
-
const wrap = (min, max, v) => {
|
|
63
|
-
const rangeSize = max - min;
|
|
64
|
-
return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const isEasingArray = (ease) => {
|
|
68
|
-
return Array.isArray(ease) && typeof ease[0] !== "number";
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
function getEasingForSegment(easing, i) {
|
|
72
|
-
return isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
|
|
76
|
-
|
|
77
|
-
/*
|
|
78
|
-
Value in range from progress
|
|
79
|
-
|
|
80
|
-
Given a lower limit and an upper limit, we return the value within
|
|
81
|
-
that range as expressed by progress (usually a number from 0 to 1)
|
|
82
|
-
|
|
83
|
-
So progress = 0.5 would change
|
|
84
|
-
|
|
85
|
-
from -------- to
|
|
86
|
-
|
|
87
|
-
to
|
|
88
|
-
|
|
89
|
-
from ---- to
|
|
90
|
-
|
|
91
|
-
E.g. from = 10, to = 20, progress = 0.5 => 15
|
|
92
|
-
|
|
93
|
-
@param [number]: Lower limit of range
|
|
94
|
-
@param [number]: Upper limit of range
|
|
95
|
-
@param [number]: The progress between lower and upper limits expressed 0-1
|
|
96
|
-
@return [number]: Value as calculated from progress within range (not limited within range)
|
|
97
|
-
*/
|
|
98
|
-
const mixNumber = (from, to, progress) => {
|
|
99
|
-
return from + (to - from) * progress;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const generateLinearEasing = (easing, duration, // as milliseconds
|
|
103
|
-
resolution = 10 // as milliseconds
|
|
104
|
-
) => {
|
|
105
|
-
let points = "";
|
|
106
|
-
const numPoints = Math.max(Math.round(duration / resolution), 2);
|
|
107
|
-
for (let i = 0; i < numPoints; i++) {
|
|
108
|
-
points += Math.round(easing(i / (numPoints - 1)) * 10000) / 10000 + ", ";
|
|
109
|
-
}
|
|
110
|
-
return `linear(${points.substring(0, points.length - 2)})`;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Implement a practical max duration for keyframe generation
|
|
115
|
-
* to prevent infinite loops
|
|
116
|
-
*/
|
|
117
|
-
const maxGeneratorDuration = 20000;
|
|
118
|
-
function calcGeneratorDuration(generator) {
|
|
119
|
-
let duration = 0;
|
|
120
|
-
const timeStep = 50;
|
|
121
|
-
let state = generator.next(duration);
|
|
122
|
-
while (!state.done && duration < maxGeneratorDuration) {
|
|
123
|
-
duration += timeStep;
|
|
124
|
-
state = generator.next(duration);
|
|
125
|
-
}
|
|
126
|
-
return duration >= maxGeneratorDuration ? Infinity : duration;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Create a progress => progress easing function from a generator.
|
|
131
|
-
*/
|
|
132
|
-
function createGeneratorEasing(options, scale = 100, createGenerator) {
|
|
133
|
-
const generator = createGenerator({ ...options, keyframes: [0, scale] });
|
|
134
|
-
const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
135
|
-
return {
|
|
136
|
-
type: "keyframes",
|
|
137
|
-
ease: (progress) => {
|
|
138
|
-
return generator.next(duration * progress).value / scale;
|
|
139
|
-
},
|
|
140
|
-
duration: millisecondsToSeconds(duration),
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function fillOffset(offset, remaining) {
|
|
145
|
-
const min = offset[offset.length - 1];
|
|
146
|
-
for (let i = 1; i <= remaining; i++) {
|
|
147
|
-
const offsetProgress = progress(0, remaining, i);
|
|
148
|
-
offset.push(mixNumber(min, 1, offsetProgress));
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function defaultOffset(arr) {
|
|
153
|
-
const offset = [0];
|
|
154
|
-
fillOffset(offset, arr.length - 1);
|
|
155
|
-
return offset;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const isNotNull = (value) => value !== null;
|
|
159
|
-
function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe, speed = 1) {
|
|
160
|
-
const resolvedKeyframes = keyframes.filter(isNotNull);
|
|
161
|
-
const useFirstKeyframe = speed < 0 || (repeat && repeatType !== "loop" && repeat % 2 === 1);
|
|
162
|
-
const index = useFirstKeyframe ? 0 : resolvedKeyframes.length - 1;
|
|
163
|
-
return !index || finalKeyframe === undefined
|
|
164
|
-
? resolvedKeyframes[index]
|
|
165
|
-
: finalKeyframe;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
class WithPromise {
|
|
169
|
-
constructor() {
|
|
170
|
-
this.updateFinished();
|
|
171
|
-
}
|
|
172
|
-
get finished() {
|
|
173
|
-
return this._finished;
|
|
174
|
-
}
|
|
175
|
-
updateFinished() {
|
|
176
|
-
this._finished = new Promise((resolve) => {
|
|
177
|
-
this.resolve = resolve;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
notifyFinished() {
|
|
181
|
-
this.resolve();
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Allows the animation to be awaited.
|
|
185
|
-
*
|
|
186
|
-
* @deprecated Use `finished` instead.
|
|
187
|
-
*/
|
|
188
|
-
then(onResolve, onReject) {
|
|
189
|
-
return this.finished.then(onResolve, onReject);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function fillWildcards(keyframes) {
|
|
194
|
-
for (let i = 1; i < keyframes.length; i++) {
|
|
195
|
-
keyframes[i] ?? (keyframes[i] = keyframes[i - 1]);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const isCSSVar = (name) => name.startsWith("--");
|
|
200
|
-
|
|
201
|
-
function setStyle(element, name, value) {
|
|
202
|
-
isCSSVar(name)
|
|
203
|
-
? element.style.setProperty(name, value)
|
|
204
|
-
: (element.style[name] = value);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const supportsScrollTimeline = /* @__PURE__ */ memo(() => window.ScrollTimeline !== undefined);
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Add the ability for test suites to manually set support flags
|
|
211
|
-
* to better test more environments.
|
|
212
|
-
*/
|
|
213
|
-
const supportsFlags = {};
|
|
214
|
-
|
|
215
|
-
function memoSupports(callback, supportsFlag) {
|
|
216
|
-
const memoized = memo(callback);
|
|
217
|
-
return () => supportsFlags[supportsFlag] ?? memoized();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const supportsLinearEasing = /*@__PURE__*/ memoSupports(() => {
|
|
221
|
-
try {
|
|
222
|
-
document
|
|
223
|
-
.createElement("div")
|
|
224
|
-
.animate({ opacity: 0 }, { easing: "linear(0, 1)" });
|
|
225
|
-
}
|
|
226
|
-
catch (e) {
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
return true;
|
|
230
|
-
}, "linearEasing");
|
|
231
|
-
|
|
232
|
-
const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
|
|
233
|
-
|
|
234
|
-
const supportedWaapiEasing = {
|
|
235
|
-
linear: "linear",
|
|
236
|
-
ease: "ease",
|
|
237
|
-
easeIn: "ease-in",
|
|
238
|
-
easeOut: "ease-out",
|
|
239
|
-
easeInOut: "ease-in-out",
|
|
240
|
-
circIn: /*@__PURE__*/ cubicBezierAsString([0, 0.65, 0.55, 1]),
|
|
241
|
-
circOut: /*@__PURE__*/ cubicBezierAsString([0.55, 0, 1, 0.45]),
|
|
242
|
-
backIn: /*@__PURE__*/ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
|
|
243
|
-
backOut: /*@__PURE__*/ cubicBezierAsString([0.33, 1.53, 0.69, 0.99]),
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
function mapEasingToNativeEasing(easing, duration) {
|
|
247
|
-
if (!easing) {
|
|
248
|
-
return undefined;
|
|
249
|
-
}
|
|
250
|
-
else if (typeof easing === "function") {
|
|
251
|
-
return supportsLinearEasing()
|
|
252
|
-
? generateLinearEasing(easing, duration)
|
|
253
|
-
: "ease-out";
|
|
254
|
-
}
|
|
255
|
-
else if (isBezierDefinition(easing)) {
|
|
256
|
-
return cubicBezierAsString(easing);
|
|
257
|
-
}
|
|
258
|
-
else if (Array.isArray(easing)) {
|
|
259
|
-
return easing.map((segmentEasing) => mapEasingToNativeEasing(segmentEasing, duration) ||
|
|
260
|
-
supportedWaapiEasing.easeOut);
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
return supportedWaapiEasing[easing];
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeOut", times, } = {}, pseudoElement = undefined) {
|
|
268
|
-
const keyframeOptions = {
|
|
269
|
-
[valueName]: keyframes,
|
|
270
|
-
};
|
|
271
|
-
if (times)
|
|
272
|
-
keyframeOptions.offset = times;
|
|
273
|
-
const easing = mapEasingToNativeEasing(ease, duration);
|
|
274
|
-
/**
|
|
275
|
-
* If this is an easing array, apply to keyframes, not animation as a whole
|
|
276
|
-
*/
|
|
277
|
-
if (Array.isArray(easing))
|
|
278
|
-
keyframeOptions.easing = easing;
|
|
279
|
-
const options = {
|
|
280
|
-
delay,
|
|
281
|
-
duration,
|
|
282
|
-
easing: !Array.isArray(easing) ? easing : "linear",
|
|
283
|
-
fill: "both",
|
|
284
|
-
iterations: repeat + 1,
|
|
285
|
-
direction: repeatType === "reverse" ? "alternate" : "normal",
|
|
286
|
-
};
|
|
287
|
-
if (pseudoElement)
|
|
288
|
-
options.pseudoElement = pseudoElement;
|
|
289
|
-
const animation = element.animate(keyframeOptions, options);
|
|
290
|
-
return animation;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function isGenerator(type) {
|
|
294
|
-
return typeof type === "function" && "applyToOptions" in type;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function applyGeneratorOptions({ type, ...options }) {
|
|
298
|
-
if (isGenerator(type) && supportsLinearEasing()) {
|
|
299
|
-
return type.applyToOptions(options);
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
options.duration ?? (options.duration = 300);
|
|
303
|
-
options.ease ?? (options.ease = "easeOut");
|
|
304
|
-
}
|
|
305
|
-
return options;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* NativeAnimation implements AnimationPlaybackControls for the browser's Web Animations API.
|
|
310
|
-
*/
|
|
311
|
-
class NativeAnimation extends WithPromise {
|
|
312
|
-
constructor(options) {
|
|
313
|
-
super();
|
|
314
|
-
this.finishedTime = null;
|
|
315
|
-
this.isStopped = false;
|
|
316
|
-
if (!options)
|
|
317
|
-
return;
|
|
318
|
-
const { element, name, keyframes, pseudoElement, allowFlatten = false, finalKeyframe, onComplete, } = options;
|
|
319
|
-
this.isPseudoElement = Boolean(pseudoElement);
|
|
320
|
-
this.allowFlatten = allowFlatten;
|
|
321
|
-
this.options = options;
|
|
322
|
-
invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "motion"?`);
|
|
323
|
-
const transition = applyGeneratorOptions(options);
|
|
324
|
-
this.animation = startWaapiAnimation(element, name, keyframes, transition, pseudoElement);
|
|
325
|
-
if (transition.autoplay === false) {
|
|
326
|
-
this.animation.pause();
|
|
327
|
-
}
|
|
328
|
-
this.animation.onfinish = () => {
|
|
329
|
-
this.finishedTime = this.time;
|
|
330
|
-
if (!pseudoElement) {
|
|
331
|
-
const keyframe = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
|
|
332
|
-
if (this.updateMotionValue) {
|
|
333
|
-
this.updateMotionValue(keyframe);
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
/**
|
|
337
|
-
* If we can, we want to commit the final style as set by the user,
|
|
338
|
-
* rather than the computed keyframe value supplied by the animation.
|
|
339
|
-
*/
|
|
340
|
-
setStyle(element, name, keyframe);
|
|
341
|
-
}
|
|
342
|
-
this.animation.cancel();
|
|
343
|
-
}
|
|
344
|
-
onComplete?.();
|
|
345
|
-
this.notifyFinished();
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
play() {
|
|
349
|
-
if (this.isStopped)
|
|
350
|
-
return;
|
|
351
|
-
this.animation.play();
|
|
352
|
-
if (this.state === "finished") {
|
|
353
|
-
this.updateFinished();
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
pause() {
|
|
357
|
-
this.animation.pause();
|
|
358
|
-
}
|
|
359
|
-
complete() {
|
|
360
|
-
this.animation.finish?.();
|
|
361
|
-
}
|
|
362
|
-
cancel() {
|
|
363
|
-
try {
|
|
364
|
-
this.animation.cancel();
|
|
365
|
-
}
|
|
366
|
-
catch (e) { }
|
|
367
|
-
}
|
|
368
|
-
stop() {
|
|
369
|
-
if (this.isStopped)
|
|
370
|
-
return;
|
|
371
|
-
this.isStopped = true;
|
|
372
|
-
const { state } = this;
|
|
373
|
-
if (state === "idle" || state === "finished") {
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
if (this.updateMotionValue) {
|
|
377
|
-
this.updateMotionValue();
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
this.commitStyles();
|
|
381
|
-
}
|
|
382
|
-
if (!this.isPseudoElement)
|
|
383
|
-
this.cancel();
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* WAAPI doesn't natively have any interruption capabilities.
|
|
387
|
-
*
|
|
388
|
-
* In this method, we commit styles back to the DOM before cancelling
|
|
389
|
-
* the animation.
|
|
390
|
-
*
|
|
391
|
-
* This is designed to be overridden by NativeAnimationExtended, which
|
|
392
|
-
* will create a renderless JS animation and sample it twice to calculate
|
|
393
|
-
* its current value, "previous" value, and therefore allow
|
|
394
|
-
* Motion to also correctly calculate velocity for any subsequent animation
|
|
395
|
-
* while deferring the commit until the next animation frame.
|
|
396
|
-
*/
|
|
397
|
-
commitStyles() {
|
|
398
|
-
if (!this.isPseudoElement) {
|
|
399
|
-
this.animation.commitStyles?.();
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
get duration() {
|
|
403
|
-
const duration = this.animation.effect?.getComputedTiming?.().duration || 0;
|
|
404
|
-
return millisecondsToSeconds(Number(duration));
|
|
405
|
-
}
|
|
406
|
-
get time() {
|
|
407
|
-
return millisecondsToSeconds(Number(this.animation.currentTime) || 0);
|
|
408
|
-
}
|
|
409
|
-
set time(newTime) {
|
|
410
|
-
this.finishedTime = null;
|
|
411
|
-
this.animation.currentTime = secondsToMilliseconds(newTime);
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* The playback speed of the animation.
|
|
415
|
-
* 1 = normal speed, 2 = double speed, 0.5 = half speed.
|
|
416
|
-
*/
|
|
417
|
-
get speed() {
|
|
418
|
-
return this.animation.playbackRate;
|
|
419
|
-
}
|
|
420
|
-
set speed(newSpeed) {
|
|
421
|
-
// Allow backwards playback after finishing
|
|
422
|
-
if (newSpeed < 0)
|
|
423
|
-
this.finishedTime = null;
|
|
424
|
-
this.animation.playbackRate = newSpeed;
|
|
425
|
-
}
|
|
426
|
-
get state() {
|
|
427
|
-
return this.finishedTime !== null
|
|
428
|
-
? "finished"
|
|
429
|
-
: this.animation.playState;
|
|
430
|
-
}
|
|
431
|
-
get startTime() {
|
|
432
|
-
return Number(this.animation.startTime);
|
|
433
|
-
}
|
|
434
|
-
set startTime(newStartTime) {
|
|
435
|
-
this.animation.startTime = newStartTime;
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Attaches a timeline to the animation, for instance the `ScrollTimeline`.
|
|
439
|
-
*/
|
|
440
|
-
attachTimeline({ timeline, observe }) {
|
|
441
|
-
if (this.allowFlatten) {
|
|
442
|
-
this.animation.effect?.updateTiming({ easing: "linear" });
|
|
443
|
-
}
|
|
444
|
-
this.animation.onfinish = null;
|
|
445
|
-
if (timeline && supportsScrollTimeline()) {
|
|
446
|
-
this.animation.timeline = timeline;
|
|
447
|
-
return noop;
|
|
448
|
-
}
|
|
449
|
-
else {
|
|
450
|
-
return observe(this);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
class GroupAnimation {
|
|
456
|
-
constructor(animations) {
|
|
457
|
-
// Bound to accomadate common `return animation.stop` pattern
|
|
458
|
-
this.stop = () => this.runAll("stop");
|
|
459
|
-
this.animations = animations.filter(Boolean);
|
|
460
|
-
}
|
|
461
|
-
get finished() {
|
|
462
|
-
return Promise.all(this.animations.map((animation) => animation.finished));
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* TODO: Filter out cancelled or stopped animations before returning
|
|
466
|
-
*/
|
|
467
|
-
getAll(propName) {
|
|
468
|
-
return this.animations[0][propName];
|
|
469
|
-
}
|
|
470
|
-
setAll(propName, newValue) {
|
|
471
|
-
for (let i = 0; i < this.animations.length; i++) {
|
|
472
|
-
this.animations[i][propName] = newValue;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
attachTimeline(timeline) {
|
|
476
|
-
const subscriptions = this.animations.map((animation) => animation.attachTimeline(timeline));
|
|
477
|
-
return () => {
|
|
478
|
-
subscriptions.forEach((cancel, i) => {
|
|
479
|
-
cancel && cancel();
|
|
480
|
-
this.animations[i].stop();
|
|
481
|
-
});
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
get time() {
|
|
485
|
-
return this.getAll("time");
|
|
486
|
-
}
|
|
487
|
-
set time(time) {
|
|
488
|
-
this.setAll("time", time);
|
|
489
|
-
}
|
|
490
|
-
get speed() {
|
|
491
|
-
return this.getAll("speed");
|
|
492
|
-
}
|
|
493
|
-
set speed(speed) {
|
|
494
|
-
this.setAll("speed", speed);
|
|
495
|
-
}
|
|
496
|
-
get state() {
|
|
497
|
-
return this.getAll("state");
|
|
498
|
-
}
|
|
499
|
-
get startTime() {
|
|
500
|
-
return this.getAll("startTime");
|
|
501
|
-
}
|
|
502
|
-
get duration() {
|
|
503
|
-
let max = 0;
|
|
504
|
-
for (let i = 0; i < this.animations.length; i++) {
|
|
505
|
-
max = Math.max(max, this.animations[i].duration);
|
|
506
|
-
}
|
|
507
|
-
return max;
|
|
508
|
-
}
|
|
509
|
-
runAll(methodName) {
|
|
510
|
-
this.animations.forEach((controls) => controls[methodName]());
|
|
511
|
-
}
|
|
512
|
-
play() {
|
|
513
|
-
this.runAll("play");
|
|
514
|
-
}
|
|
515
|
-
pause() {
|
|
516
|
-
this.runAll("pause");
|
|
517
|
-
}
|
|
518
|
-
cancel() {
|
|
519
|
-
this.runAll("cancel");
|
|
520
|
-
}
|
|
521
|
-
complete() {
|
|
522
|
-
this.runAll("complete");
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
class GroupAnimationWithThen extends GroupAnimation {
|
|
527
|
-
then(onResolve, _onReject) {
|
|
528
|
-
return this.finished.finally(onResolve).then(() => { });
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
const animationMaps = new WeakMap();
|
|
533
|
-
const animationMapKey = (name, pseudoElement = "") => `${name}:${pseudoElement}`;
|
|
534
|
-
function getAnimationMap(element) {
|
|
535
|
-
const map = animationMaps.get(element) || new Map();
|
|
536
|
-
animationMaps.set(element, map);
|
|
537
|
-
return map;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
function getValueTransition$1(transition, key) {
|
|
541
|
-
return (transition?.[key] ??
|
|
542
|
-
transition?.["default"] ??
|
|
543
|
-
transition);
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
const pxValues = new Set([
|
|
547
|
-
// Border props
|
|
548
|
-
"borderWidth",
|
|
549
|
-
"borderTopWidth",
|
|
550
|
-
"borderRightWidth",
|
|
551
|
-
"borderBottomWidth",
|
|
552
|
-
"borderLeftWidth",
|
|
553
|
-
"borderRadius",
|
|
554
|
-
"radius",
|
|
555
|
-
"borderTopLeftRadius",
|
|
556
|
-
"borderTopRightRadius",
|
|
557
|
-
"borderBottomRightRadius",
|
|
558
|
-
"borderBottomLeftRadius",
|
|
559
|
-
// Positioning props
|
|
560
|
-
"width",
|
|
561
|
-
"maxWidth",
|
|
562
|
-
"height",
|
|
563
|
-
"maxHeight",
|
|
564
|
-
"top",
|
|
565
|
-
"right",
|
|
566
|
-
"bottom",
|
|
567
|
-
"left",
|
|
568
|
-
// Spacing props
|
|
569
|
-
"padding",
|
|
570
|
-
"paddingTop",
|
|
571
|
-
"paddingRight",
|
|
572
|
-
"paddingBottom",
|
|
573
|
-
"paddingLeft",
|
|
574
|
-
"margin",
|
|
575
|
-
"marginTop",
|
|
576
|
-
"marginRight",
|
|
577
|
-
"marginBottom",
|
|
578
|
-
"marginLeft",
|
|
579
|
-
// Misc
|
|
580
|
-
"backgroundPositionX",
|
|
581
|
-
"backgroundPositionY",
|
|
582
|
-
]);
|
|
583
|
-
|
|
584
|
-
function applyPxDefaults(keyframes, name) {
|
|
585
|
-
for (let i = 0; i < keyframes.length; i++) {
|
|
586
|
-
if (typeof keyframes[i] === "number" && pxValues.has(name)) {
|
|
587
|
-
keyframes[i] = keyframes[i] + "px";
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
593
|
-
if (elementOrSelector instanceof EventTarget) {
|
|
594
|
-
return [elementOrSelector];
|
|
595
|
-
}
|
|
596
|
-
else if (typeof elementOrSelector === "string") {
|
|
597
|
-
let root = document;
|
|
598
|
-
if (scope) {
|
|
599
|
-
root = scope.current;
|
|
600
|
-
}
|
|
601
|
-
const elements = selectorCache?.[elementOrSelector] ??
|
|
602
|
-
root.querySelectorAll(elementOrSelector);
|
|
603
|
-
return elements ? Array.from(elements) : [];
|
|
604
|
-
}
|
|
605
|
-
return Array.from(elementOrSelector);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
function getComputedStyle(element, name) {
|
|
609
|
-
const computedStyle = window.getComputedStyle(element);
|
|
610
|
-
return isCSSVar(name)
|
|
611
|
-
? computedStyle.getPropertyValue(name)
|
|
612
|
-
: computedStyle[name];
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
const isMotionValue = (value) => Boolean(value && value.getVelocity);
|
|
616
|
-
|
|
617
|
-
function isDOMKeyframes(keyframes) {
|
|
618
|
-
return typeof keyframes === "object" && !Array.isArray(keyframes);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
function resolveSubjects(subject, keyframes, scope, selectorCache) {
|
|
622
|
-
if (typeof subject === "string" && isDOMKeyframes(keyframes)) {
|
|
623
|
-
return resolveElements(subject, scope, selectorCache);
|
|
624
|
-
}
|
|
625
|
-
else if (subject instanceof NodeList) {
|
|
626
|
-
return Array.from(subject);
|
|
627
|
-
}
|
|
628
|
-
else if (Array.isArray(subject)) {
|
|
629
|
-
return subject;
|
|
630
|
-
}
|
|
631
|
-
else {
|
|
632
|
-
return [subject];
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
function calculateRepeatDuration(duration, repeat, _repeatDelay) {
|
|
637
|
-
return duration * (repeat + 1);
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Given a absolute or relative time definition and current/prev time state of the sequence,
|
|
642
|
-
* calculate an absolute time for the next keyframes.
|
|
643
|
-
*/
|
|
644
|
-
function calcNextTime(current, next, prev, labels) {
|
|
645
|
-
if (typeof next === "number") {
|
|
646
|
-
return next;
|
|
647
|
-
}
|
|
648
|
-
else if (next.startsWith("-") || next.startsWith("+")) {
|
|
649
|
-
return Math.max(0, current + parseFloat(next));
|
|
650
|
-
}
|
|
651
|
-
else if (next === "<") {
|
|
652
|
-
return prev;
|
|
653
|
-
}
|
|
654
|
-
else if (next.startsWith("<")) {
|
|
655
|
-
return Math.max(0, prev + parseFloat(next.slice(1)));
|
|
656
|
-
}
|
|
657
|
-
else {
|
|
658
|
-
return labels.get(next) ?? current;
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
function eraseKeyframes(sequence, startTime, endTime) {
|
|
663
|
-
for (let i = 0; i < sequence.length; i++) {
|
|
664
|
-
const keyframe = sequence[i];
|
|
665
|
-
if (keyframe.at > startTime && keyframe.at < endTime) {
|
|
666
|
-
removeItem(sequence, keyframe);
|
|
667
|
-
// If we remove this item we have to push the pointer back one
|
|
668
|
-
i--;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
function addKeyframes(sequence, keyframes, easing, offset, startTime, endTime) {
|
|
673
|
-
/**
|
|
674
|
-
* Erase every existing value between currentTime and targetTime,
|
|
675
|
-
* this will essentially splice this timeline into any currently
|
|
676
|
-
* defined ones.
|
|
677
|
-
*/
|
|
678
|
-
eraseKeyframes(sequence, startTime, endTime);
|
|
679
|
-
for (let i = 0; i < keyframes.length; i++) {
|
|
680
|
-
sequence.push({
|
|
681
|
-
value: keyframes[i],
|
|
682
|
-
at: mixNumber(startTime, endTime, offset[i]),
|
|
683
|
-
easing: getEasingForSegment(easing, i),
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* Take an array of times that represent repeated keyframes. For instance
|
|
690
|
-
* if we have original times of [0, 0.5, 1] then our repeated times will
|
|
691
|
-
* be [0, 0.5, 1, 1, 1.5, 2]. Loop over the times and scale them back
|
|
692
|
-
* down to a 0-1 scale.
|
|
693
|
-
*/
|
|
694
|
-
function normalizeTimes(times, repeat) {
|
|
695
|
-
for (let i = 0; i < times.length; i++) {
|
|
696
|
-
times[i] = times[i] / (repeat + 1);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
function compareByTime(a, b) {
|
|
701
|
-
if (a.at === b.at) {
|
|
702
|
-
if (a.value === null)
|
|
703
|
-
return 1;
|
|
704
|
-
if (b.value === null)
|
|
705
|
-
return -1;
|
|
706
|
-
return 0;
|
|
707
|
-
}
|
|
708
|
-
else {
|
|
709
|
-
return a.at - b.at;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
const defaultSegmentEasing = "easeInOut";
|
|
714
|
-
const MAX_REPEAT = 20;
|
|
715
|
-
function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...sequenceTransition } = {}, scope, generators) {
|
|
716
|
-
const defaultDuration = defaultTransition.duration || 0.3;
|
|
717
|
-
const animationDefinitions = new Map();
|
|
718
|
-
const sequences = new Map();
|
|
719
|
-
const elementCache = {};
|
|
720
|
-
const timeLabels = new Map();
|
|
721
|
-
let prevTime = 0;
|
|
722
|
-
let currentTime = 0;
|
|
723
|
-
let totalDuration = 0;
|
|
724
|
-
/**
|
|
725
|
-
* Build the timeline by mapping over the sequence array and converting
|
|
726
|
-
* the definitions into keyframes and offsets with absolute time values.
|
|
727
|
-
* These will later get converted into relative offsets in a second pass.
|
|
728
|
-
*/
|
|
729
|
-
for (let i = 0; i < sequence.length; i++) {
|
|
730
|
-
const segment = sequence[i];
|
|
731
|
-
/**
|
|
732
|
-
* If this is a timeline label, mark it and skip the rest of this iteration.
|
|
733
|
-
*/
|
|
734
|
-
if (typeof segment === "string") {
|
|
735
|
-
timeLabels.set(segment, currentTime);
|
|
736
|
-
continue;
|
|
737
|
-
}
|
|
738
|
-
else if (!Array.isArray(segment)) {
|
|
739
|
-
timeLabels.set(segment.name, calcNextTime(currentTime, segment.at, prevTime, timeLabels));
|
|
740
|
-
continue;
|
|
741
|
-
}
|
|
742
|
-
let [subject, keyframes, transition = {}] = segment;
|
|
743
|
-
/**
|
|
744
|
-
* If a relative or absolute time value has been specified we need to resolve
|
|
745
|
-
* it in relation to the currentTime.
|
|
746
|
-
*/
|
|
747
|
-
if (transition.at !== undefined) {
|
|
748
|
-
currentTime = calcNextTime(currentTime, transition.at, prevTime, timeLabels);
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* Keep track of the maximum duration in this definition. This will be
|
|
752
|
-
* applied to currentTime once the definition has been parsed.
|
|
753
|
-
*/
|
|
754
|
-
let maxDuration = 0;
|
|
755
|
-
const resolveValueSequence = (valueKeyframes, valueTransition, valueSequence, elementIndex = 0, numSubjects = 0) => {
|
|
756
|
-
const valueKeyframesAsList = keyframesAsList(valueKeyframes);
|
|
757
|
-
const { delay = 0, times = defaultOffset(valueKeyframesAsList), type = "keyframes", repeat, repeatType, repeatDelay = 0, ...remainingTransition } = valueTransition;
|
|
758
|
-
let { ease = defaultTransition.ease || "easeOut", duration } = valueTransition;
|
|
759
|
-
/**
|
|
760
|
-
* Resolve stagger() if defined.
|
|
761
|
-
*/
|
|
762
|
-
const calculatedDelay = typeof delay === "function"
|
|
763
|
-
? delay(elementIndex, numSubjects)
|
|
764
|
-
: delay;
|
|
765
|
-
/**
|
|
766
|
-
* If this animation should and can use a spring, generate a spring easing function.
|
|
767
|
-
*/
|
|
768
|
-
const numKeyframes = valueKeyframesAsList.length;
|
|
769
|
-
const createGenerator = isGenerator(type)
|
|
770
|
-
? type
|
|
771
|
-
: generators?.[type || "keyframes"];
|
|
772
|
-
if (numKeyframes <= 2 && createGenerator) {
|
|
773
|
-
/**
|
|
774
|
-
* As we're creating an easing function from a spring,
|
|
775
|
-
* ideally we want to generate it using the real distance
|
|
776
|
-
* between the two keyframes. However this isn't always
|
|
777
|
-
* possible - in these situations we use 0-100.
|
|
778
|
-
*/
|
|
779
|
-
let absoluteDelta = 100;
|
|
780
|
-
if (numKeyframes === 2 &&
|
|
781
|
-
isNumberKeyframesArray(valueKeyframesAsList)) {
|
|
782
|
-
const delta = valueKeyframesAsList[1] - valueKeyframesAsList[0];
|
|
783
|
-
absoluteDelta = Math.abs(delta);
|
|
784
|
-
}
|
|
785
|
-
const springTransition = { ...remainingTransition };
|
|
786
|
-
if (duration !== undefined) {
|
|
787
|
-
springTransition.duration = secondsToMilliseconds(duration);
|
|
788
|
-
}
|
|
789
|
-
const springEasing = createGeneratorEasing(springTransition, absoluteDelta, createGenerator);
|
|
790
|
-
ease = springEasing.ease;
|
|
791
|
-
duration = springEasing.duration;
|
|
792
|
-
}
|
|
793
|
-
duration ?? (duration = defaultDuration);
|
|
794
|
-
const startTime = currentTime + calculatedDelay;
|
|
795
|
-
/**
|
|
796
|
-
* If there's only one time offset of 0, fill in a second with length 1
|
|
797
|
-
*/
|
|
798
|
-
if (times.length === 1 && times[0] === 0) {
|
|
799
|
-
times[1] = 1;
|
|
800
|
-
}
|
|
801
|
-
/**
|
|
802
|
-
* Fill out if offset if fewer offsets than keyframes
|
|
803
|
-
*/
|
|
804
|
-
const remainder = times.length - valueKeyframesAsList.length;
|
|
805
|
-
remainder > 0 && fillOffset(times, remainder);
|
|
806
|
-
/**
|
|
807
|
-
* If only one value has been set, ie [1], push a null to the start of
|
|
808
|
-
* the keyframe array. This will let us mark a keyframe at this point
|
|
809
|
-
* that will later be hydrated with the previous value.
|
|
810
|
-
*/
|
|
811
|
-
valueKeyframesAsList.length === 1 &&
|
|
812
|
-
valueKeyframesAsList.unshift(null);
|
|
813
|
-
/**
|
|
814
|
-
* Handle repeat options
|
|
815
|
-
*/
|
|
816
|
-
if (repeat) {
|
|
817
|
-
invariant(repeat < MAX_REPEAT, "Repeat count too high, must be less than 20");
|
|
818
|
-
duration = calculateRepeatDuration(duration, repeat);
|
|
819
|
-
const originalKeyframes = [...valueKeyframesAsList];
|
|
820
|
-
const originalTimes = [...times];
|
|
821
|
-
ease = Array.isArray(ease) ? [...ease] : [ease];
|
|
822
|
-
const originalEase = [...ease];
|
|
823
|
-
for (let repeatIndex = 0; repeatIndex < repeat; repeatIndex++) {
|
|
824
|
-
valueKeyframesAsList.push(...originalKeyframes);
|
|
825
|
-
for (let keyframeIndex = 0; keyframeIndex < originalKeyframes.length; keyframeIndex++) {
|
|
826
|
-
times.push(originalTimes[keyframeIndex] + (repeatIndex + 1));
|
|
827
|
-
ease.push(keyframeIndex === 0
|
|
828
|
-
? "linear"
|
|
829
|
-
: getEasingForSegment(originalEase, keyframeIndex - 1));
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
normalizeTimes(times, repeat);
|
|
833
|
-
}
|
|
834
|
-
const targetTime = startTime + duration;
|
|
835
|
-
/**
|
|
836
|
-
* Add keyframes, mapping offsets to absolute time.
|
|
837
|
-
*/
|
|
838
|
-
addKeyframes(valueSequence, valueKeyframesAsList, ease, times, startTime, targetTime);
|
|
839
|
-
maxDuration = Math.max(calculatedDelay + duration, maxDuration);
|
|
840
|
-
totalDuration = Math.max(targetTime, totalDuration);
|
|
841
|
-
};
|
|
842
|
-
if (isMotionValue(subject)) {
|
|
843
|
-
const subjectSequence = getSubjectSequence(subject, sequences);
|
|
844
|
-
resolveValueSequence(keyframes, transition, getValueSequence("default", subjectSequence));
|
|
845
|
-
}
|
|
846
|
-
else {
|
|
847
|
-
const subjects = resolveSubjects(subject, keyframes, scope, elementCache);
|
|
848
|
-
const numSubjects = subjects.length;
|
|
849
|
-
/**
|
|
850
|
-
* For every element in this segment, process the defined values.
|
|
851
|
-
*/
|
|
852
|
-
for (let subjectIndex = 0; subjectIndex < numSubjects; subjectIndex++) {
|
|
853
|
-
/**
|
|
854
|
-
* Cast necessary, but we know these are of this type
|
|
855
|
-
*/
|
|
856
|
-
keyframes = keyframes;
|
|
857
|
-
transition = transition;
|
|
858
|
-
const thisSubject = subjects[subjectIndex];
|
|
859
|
-
const subjectSequence = getSubjectSequence(thisSubject, sequences);
|
|
860
|
-
for (const key in keyframes) {
|
|
861
|
-
resolveValueSequence(keyframes[key], getValueTransition(transition, key), getValueSequence(key, subjectSequence), subjectIndex, numSubjects);
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
prevTime = currentTime;
|
|
866
|
-
currentTime += maxDuration;
|
|
867
|
-
}
|
|
868
|
-
/**
|
|
869
|
-
* For every element and value combination create a new animation.
|
|
870
|
-
*/
|
|
871
|
-
sequences.forEach((valueSequences, element) => {
|
|
872
|
-
for (const key in valueSequences) {
|
|
873
|
-
const valueSequence = valueSequences[key];
|
|
874
|
-
/**
|
|
875
|
-
* Arrange all the keyframes in ascending time order.
|
|
876
|
-
*/
|
|
877
|
-
valueSequence.sort(compareByTime);
|
|
878
|
-
const keyframes = [];
|
|
879
|
-
const valueOffset = [];
|
|
880
|
-
const valueEasing = [];
|
|
881
|
-
/**
|
|
882
|
-
* For each keyframe, translate absolute times into
|
|
883
|
-
* relative offsets based on the total duration of the timeline.
|
|
884
|
-
*/
|
|
885
|
-
for (let i = 0; i < valueSequence.length; i++) {
|
|
886
|
-
const { at, value, easing } = valueSequence[i];
|
|
887
|
-
keyframes.push(value);
|
|
888
|
-
valueOffset.push(progress(0, totalDuration, at));
|
|
889
|
-
valueEasing.push(easing || "easeOut");
|
|
890
|
-
}
|
|
891
|
-
/**
|
|
892
|
-
* If the first keyframe doesn't land on offset: 0
|
|
893
|
-
* provide one by duplicating the initial keyframe. This ensures
|
|
894
|
-
* it snaps to the first keyframe when the animation starts.
|
|
895
|
-
*/
|
|
896
|
-
if (valueOffset[0] !== 0) {
|
|
897
|
-
valueOffset.unshift(0);
|
|
898
|
-
keyframes.unshift(keyframes[0]);
|
|
899
|
-
valueEasing.unshift(defaultSegmentEasing);
|
|
900
|
-
}
|
|
901
|
-
/**
|
|
902
|
-
* If the last keyframe doesn't land on offset: 1
|
|
903
|
-
* provide one with a null wildcard value. This will ensure it
|
|
904
|
-
* stays static until the end of the animation.
|
|
905
|
-
*/
|
|
906
|
-
if (valueOffset[valueOffset.length - 1] !== 1) {
|
|
907
|
-
valueOffset.push(1);
|
|
908
|
-
keyframes.push(null);
|
|
909
|
-
}
|
|
910
|
-
if (!animationDefinitions.has(element)) {
|
|
911
|
-
animationDefinitions.set(element, {
|
|
912
|
-
keyframes: {},
|
|
913
|
-
transition: {},
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
const definition = animationDefinitions.get(element);
|
|
917
|
-
definition.keyframes[key] = keyframes;
|
|
918
|
-
definition.transition[key] = {
|
|
919
|
-
...defaultTransition,
|
|
920
|
-
duration: totalDuration,
|
|
921
|
-
ease: valueEasing,
|
|
922
|
-
times: valueOffset,
|
|
923
|
-
...sequenceTransition,
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
return animationDefinitions;
|
|
928
|
-
}
|
|
929
|
-
function getSubjectSequence(subject, sequences) {
|
|
930
|
-
!sequences.has(subject) && sequences.set(subject, {});
|
|
931
|
-
return sequences.get(subject);
|
|
932
|
-
}
|
|
933
|
-
function getValueSequence(name, sequences) {
|
|
934
|
-
if (!sequences[name])
|
|
935
|
-
sequences[name] = [];
|
|
936
|
-
return sequences[name];
|
|
937
|
-
}
|
|
938
|
-
function keyframesAsList(keyframes) {
|
|
939
|
-
return Array.isArray(keyframes) ? keyframes : [keyframes];
|
|
940
|
-
}
|
|
941
|
-
function getValueTransition(transition, key) {
|
|
942
|
-
return transition && transition[key]
|
|
943
|
-
? {
|
|
944
|
-
...transition,
|
|
945
|
-
...transition[key],
|
|
946
|
-
}
|
|
947
|
-
: { ...transition };
|
|
948
|
-
}
|
|
949
|
-
const isNumber = (keyframe) => typeof keyframe === "number";
|
|
950
|
-
const isNumberKeyframesArray = (keyframes) => keyframes.every(isNumber);
|
|
951
|
-
|
|
952
|
-
function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
953
|
-
const elements = resolveElements(elementOrSelector, scope);
|
|
954
|
-
const numElements = elements.length;
|
|
955
|
-
invariant(Boolean(numElements), "No valid element provided.");
|
|
956
|
-
/**
|
|
957
|
-
* WAAPI doesn't support interrupting animations.
|
|
958
|
-
*
|
|
959
|
-
* Therefore, starting animations requires a three-step process:
|
|
960
|
-
* 1. Stop existing animations (write styles to DOM)
|
|
961
|
-
* 2. Resolve keyframes (read styles from DOM)
|
|
962
|
-
* 3. Create new animations (write styles to DOM)
|
|
963
|
-
*
|
|
964
|
-
* The hybrid `animate()` function uses AsyncAnimation to resolve
|
|
965
|
-
* keyframes before creating new animations, which removes style
|
|
966
|
-
* thrashing. Here, we have much stricter filesize constraints.
|
|
967
|
-
* Therefore we do this in a synchronous way that ensures that
|
|
968
|
-
* at least within `animate()` calls there is no style thrashing.
|
|
969
|
-
*
|
|
970
|
-
* In the motion-native-animate-mini-interrupt benchmark this
|
|
971
|
-
* was 80% faster than a single loop.
|
|
972
|
-
*/
|
|
973
|
-
const animationDefinitions = [];
|
|
974
|
-
/**
|
|
975
|
-
* Step 1: Build options and stop existing animations (write)
|
|
976
|
-
*/
|
|
977
|
-
for (let i = 0; i < numElements; i++) {
|
|
978
|
-
const element = elements[i];
|
|
979
|
-
const elementTransition = { ...options };
|
|
980
|
-
/**
|
|
981
|
-
* Resolve stagger function if provided.
|
|
982
|
-
*/
|
|
983
|
-
if (typeof elementTransition.delay === "function") {
|
|
984
|
-
elementTransition.delay = elementTransition.delay(i, numElements);
|
|
985
|
-
}
|
|
986
|
-
for (const valueName in keyframes) {
|
|
987
|
-
let valueKeyframes = keyframes[valueName];
|
|
988
|
-
if (!Array.isArray(valueKeyframes)) {
|
|
989
|
-
valueKeyframes = [valueKeyframes];
|
|
990
|
-
}
|
|
991
|
-
const valueOptions = {
|
|
992
|
-
...getValueTransition$1(elementTransition, valueName),
|
|
993
|
-
};
|
|
994
|
-
valueOptions.duration && (valueOptions.duration = secondsToMilliseconds(valueOptions.duration));
|
|
995
|
-
valueOptions.delay && (valueOptions.delay = secondsToMilliseconds(valueOptions.delay));
|
|
996
|
-
/**
|
|
997
|
-
* If there's an existing animation playing on this element then stop it
|
|
998
|
-
* before creating a new one.
|
|
999
|
-
*/
|
|
1000
|
-
const map = getAnimationMap(element);
|
|
1001
|
-
const key = animationMapKey(valueName, valueOptions.pseudoElement || "");
|
|
1002
|
-
const currentAnimation = map.get(key);
|
|
1003
|
-
currentAnimation && currentAnimation.stop();
|
|
1004
|
-
animationDefinitions.push({
|
|
1005
|
-
map,
|
|
1006
|
-
key,
|
|
1007
|
-
unresolvedKeyframes: valueKeyframes,
|
|
1008
|
-
options: {
|
|
1009
|
-
...valueOptions,
|
|
1010
|
-
element,
|
|
1011
|
-
name: valueName,
|
|
1012
|
-
allowFlatten: !elementTransition.type && !elementTransition.ease,
|
|
1013
|
-
},
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
/**
|
|
1018
|
-
* Step 2: Resolve keyframes (read)
|
|
1019
|
-
*/
|
|
1020
|
-
for (let i = 0; i < animationDefinitions.length; i++) {
|
|
1021
|
-
const { unresolvedKeyframes, options: animationOptions } = animationDefinitions[i];
|
|
1022
|
-
const { element, name, pseudoElement } = animationOptions;
|
|
1023
|
-
if (!pseudoElement && unresolvedKeyframes[0] === null) {
|
|
1024
|
-
unresolvedKeyframes[0] = getComputedStyle(element, name);
|
|
1025
|
-
}
|
|
1026
|
-
fillWildcards(unresolvedKeyframes);
|
|
1027
|
-
applyPxDefaults(unresolvedKeyframes, name);
|
|
1028
|
-
/**
|
|
1029
|
-
* If we only have one keyframe, explicitly read the initial keyframe
|
|
1030
|
-
* from the computed style. This is to ensure consistency with WAAPI behaviour
|
|
1031
|
-
* for restarting animations, for instance .play() after finish, when it
|
|
1032
|
-
* has one vs two keyframes.
|
|
1033
|
-
*/
|
|
1034
|
-
if (!pseudoElement && unresolvedKeyframes.length < 2) {
|
|
1035
|
-
unresolvedKeyframes.unshift(getComputedStyle(element, name));
|
|
1036
|
-
}
|
|
1037
|
-
animationOptions.keyframes = unresolvedKeyframes;
|
|
1038
|
-
}
|
|
1039
|
-
/**
|
|
1040
|
-
* Step 3: Create new animations (write)
|
|
1041
|
-
*/
|
|
1042
|
-
const animations = [];
|
|
1043
|
-
for (let i = 0; i < animationDefinitions.length; i++) {
|
|
1044
|
-
const { map, key, options: animationOptions } = animationDefinitions[i];
|
|
1045
|
-
const animation = new NativeAnimation(animationOptions);
|
|
1046
|
-
map.set(key, animation);
|
|
1047
|
-
animation.finished.finally(() => map.delete(key));
|
|
1048
|
-
animations.push(animation);
|
|
1049
|
-
}
|
|
1050
|
-
return animations;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
function animateSequence(definition, options) {
|
|
1054
|
-
const animations = [];
|
|
1055
|
-
createAnimationsFromSequence(definition, options).forEach(({ keyframes, transition }, element) => {
|
|
1056
|
-
animations.push(...animateElements(element, keyframes, transition));
|
|
1057
|
-
});
|
|
1058
|
-
return new GroupAnimationWithThen(animations);
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
const createScopedWaapiAnimate = (scope) => {
|
|
1062
|
-
function scopedAnimate(elementOrSelector, keyframes, options) {
|
|
1063
|
-
return new GroupAnimationWithThen(animateElements(elementOrSelector, keyframes, options, scope));
|
|
1064
|
-
}
|
|
1065
|
-
return scopedAnimate;
|
|
1066
|
-
};
|
|
1067
|
-
const animateMini = /*@__PURE__*/ createScopedWaapiAnimate();
|
|
1068
|
-
|
|
1069
|
-
exports.animate = animateMini;
|
|
1070
|
-
exports.animateSequence = animateSequence;
|
|
9
|
+
Object.keys(mini).forEach(function (k) {
|
|
10
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return mini[k]; }
|
|
13
|
+
});
|
|
14
|
+
});
|