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
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
import { animateMotionValue } from '../../animation/interfaces/motion-value.mjs';
|
|
2
|
-
import { addDomEvent } from '../../events/add-dom-event.mjs';
|
|
3
|
-
import { addPointerEvent } from '../../events/add-pointer-event.mjs';
|
|
4
|
-
import { extractEventInfo } from '../../events/event-info.mjs';
|
|
5
|
-
import { convertBoxToBoundingBox, convertBoundingBoxToBox } from '../../projection/geometry/conversion.mjs';
|
|
6
|
-
import { calcLength } from '../../projection/geometry/delta-calc.mjs';
|
|
7
|
-
import { createBox } from '../../projection/geometry/models.mjs';
|
|
8
|
-
import { eachAxis } from '../../projection/utils/each-axis.mjs';
|
|
9
|
-
import { measurePageBox } from '../../projection/utils/measure.mjs';
|
|
10
|
-
import { getContextWindow } from '../../utils/get-context-window.mjs';
|
|
11
|
-
import { isRefObject } from '../../utils/is-ref-object.mjs';
|
|
12
|
-
import { addValueToWillChange } from '../../value/use-will-change/add-will-change.mjs';
|
|
13
|
-
import { PanSession } from '../pan/PanSession.mjs';
|
|
14
|
-
import { applyConstraints, calcRelativeConstraints, resolveDragElastic, calcViewportConstraints, rebaseAxisConstraints, calcOrigin, defaultElastic } from './utils/constraints.mjs';
|
|
15
|
-
import { frame } from '../../../../../motion-dom/dist/es/frameloop/frame.mjs';
|
|
16
|
-
import { invariant } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
17
|
-
import { setDragLock } from '../../../../../motion-dom/dist/es/gestures/drag/state/set-active.mjs';
|
|
18
|
-
import { percent } from '../../../../../motion-dom/dist/es/value/types/numbers/units.mjs';
|
|
19
|
-
import { mixNumber } from '../../../../../motion-dom/dist/es/utils/mix/number.mjs';
|
|
20
|
-
|
|
21
|
-
const elementDragControls = new WeakMap();
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
// let latestPointerEvent: PointerEvent
|
|
26
|
-
class VisualElementDragControls {
|
|
27
|
-
constructor(visualElement) {
|
|
28
|
-
this.openDragLock = null;
|
|
29
|
-
this.isDragging = false;
|
|
30
|
-
this.currentDirection = null;
|
|
31
|
-
this.originPoint = { x: 0, y: 0 };
|
|
32
|
-
/**
|
|
33
|
-
* The permitted boundaries of travel, in pixels.
|
|
34
|
-
*/
|
|
35
|
-
this.constraints = false;
|
|
36
|
-
this.hasMutatedConstraints = false;
|
|
37
|
-
/**
|
|
38
|
-
* The per-axis resolved elastic values.
|
|
39
|
-
*/
|
|
40
|
-
this.elastic = createBox();
|
|
41
|
-
this.visualElement = visualElement;
|
|
42
|
-
}
|
|
43
|
-
start(originEvent, { snapToCursor = false } = {}) {
|
|
44
|
-
/**
|
|
45
|
-
* Don't start dragging if this component is exiting
|
|
46
|
-
*/
|
|
47
|
-
const { presenceContext } = this.visualElement;
|
|
48
|
-
if (presenceContext && presenceContext.isPresent === false)
|
|
49
|
-
return;
|
|
50
|
-
const onSessionStart = (event) => {
|
|
51
|
-
const { dragSnapToOrigin } = this.getProps();
|
|
52
|
-
// Stop or pause any animations on both axis values immediately. This allows the user to throw and catch
|
|
53
|
-
// the component.
|
|
54
|
-
dragSnapToOrigin ? this.pauseAnimation() : this.stopAnimation();
|
|
55
|
-
if (snapToCursor) {
|
|
56
|
-
this.snapToCursor(extractEventInfo(event).point);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const onStart = (event, info) => {
|
|
60
|
-
// Attempt to grab the global drag gesture lock - maybe make this part of PanSession
|
|
61
|
-
const { drag, dragPropagation, onDragStart } = this.getProps();
|
|
62
|
-
if (drag && !dragPropagation) {
|
|
63
|
-
if (this.openDragLock)
|
|
64
|
-
this.openDragLock();
|
|
65
|
-
this.openDragLock = setDragLock(drag);
|
|
66
|
-
// If we don 't have the lock, don't start dragging
|
|
67
|
-
if (!this.openDragLock)
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
this.isDragging = true;
|
|
71
|
-
this.currentDirection = null;
|
|
72
|
-
this.resolveConstraints();
|
|
73
|
-
if (this.visualElement.projection) {
|
|
74
|
-
this.visualElement.projection.isAnimationBlocked = true;
|
|
75
|
-
this.visualElement.projection.target = undefined;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Record gesture origin
|
|
79
|
-
*/
|
|
80
|
-
eachAxis((axis) => {
|
|
81
|
-
let current = this.getAxisMotionValue(axis).get() || 0;
|
|
82
|
-
/**
|
|
83
|
-
* If the MotionValue is a percentage value convert to px
|
|
84
|
-
*/
|
|
85
|
-
if (percent.test(current)) {
|
|
86
|
-
const { projection } = this.visualElement;
|
|
87
|
-
if (projection && projection.layout) {
|
|
88
|
-
const measuredAxis = projection.layout.layoutBox[axis];
|
|
89
|
-
if (measuredAxis) {
|
|
90
|
-
const length = calcLength(measuredAxis);
|
|
91
|
-
current = length * (parseFloat(current) / 100);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
this.originPoint[axis] = current;
|
|
96
|
-
});
|
|
97
|
-
// Fire onDragStart event
|
|
98
|
-
if (onDragStart) {
|
|
99
|
-
frame.postRender(() => onDragStart(event, info));
|
|
100
|
-
}
|
|
101
|
-
addValueToWillChange(this.visualElement, "transform");
|
|
102
|
-
const { animationState } = this.visualElement;
|
|
103
|
-
animationState && animationState.setActive("whileDrag", true);
|
|
104
|
-
};
|
|
105
|
-
const onMove = (event, info) => {
|
|
106
|
-
// latestPointerEvent = event
|
|
107
|
-
const { dragPropagation, dragDirectionLock, onDirectionLock, onDrag, } = this.getProps();
|
|
108
|
-
// If we didn't successfully receive the gesture lock, early return.
|
|
109
|
-
if (!dragPropagation && !this.openDragLock)
|
|
110
|
-
return;
|
|
111
|
-
const { offset } = info;
|
|
112
|
-
// Attempt to detect drag direction if directionLock is true
|
|
113
|
-
if (dragDirectionLock && this.currentDirection === null) {
|
|
114
|
-
this.currentDirection = getCurrentDirection(offset);
|
|
115
|
-
// If we've successfully set a direction, notify listener
|
|
116
|
-
if (this.currentDirection !== null) {
|
|
117
|
-
onDirectionLock && onDirectionLock(this.currentDirection);
|
|
118
|
-
}
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
// Update each point with the latest position
|
|
122
|
-
this.updateAxis("x", info.point, offset);
|
|
123
|
-
this.updateAxis("y", info.point, offset);
|
|
124
|
-
/**
|
|
125
|
-
* Ideally we would leave the renderer to fire naturally at the end of
|
|
126
|
-
* this frame but if the element is about to change layout as the result
|
|
127
|
-
* of a re-render we want to ensure the browser can read the latest
|
|
128
|
-
* bounding box to ensure the pointer and element don't fall out of sync.
|
|
129
|
-
*/
|
|
130
|
-
this.visualElement.render();
|
|
131
|
-
/**
|
|
132
|
-
* This must fire after the render call as it might trigger a state
|
|
133
|
-
* change which itself might trigger a layout update.
|
|
134
|
-
*/
|
|
135
|
-
onDrag && onDrag(event, info);
|
|
136
|
-
};
|
|
137
|
-
const onSessionEnd = (event, info) => this.stop(event, info);
|
|
138
|
-
const resumeAnimation = () => eachAxis((axis) => this.getAnimationState(axis) === "paused" &&
|
|
139
|
-
this.getAxisMotionValue(axis).animation?.play());
|
|
140
|
-
const { dragSnapToOrigin } = this.getProps();
|
|
141
|
-
this.panSession = new PanSession(originEvent, {
|
|
142
|
-
onSessionStart,
|
|
143
|
-
onStart,
|
|
144
|
-
onMove,
|
|
145
|
-
onSessionEnd,
|
|
146
|
-
resumeAnimation,
|
|
147
|
-
}, {
|
|
148
|
-
transformPagePoint: this.visualElement.getTransformPagePoint(),
|
|
149
|
-
dragSnapToOrigin,
|
|
150
|
-
contextWindow: getContextWindow(this.visualElement),
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
stop(event, info) {
|
|
154
|
-
const isDragging = this.isDragging;
|
|
155
|
-
this.cancel();
|
|
156
|
-
if (!isDragging)
|
|
157
|
-
return;
|
|
158
|
-
const { velocity } = info;
|
|
159
|
-
this.startAnimation(velocity);
|
|
160
|
-
const { onDragEnd } = this.getProps();
|
|
161
|
-
if (onDragEnd) {
|
|
162
|
-
frame.postRender(() => onDragEnd(event, info));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
cancel() {
|
|
166
|
-
this.isDragging = false;
|
|
167
|
-
const { projection, animationState } = this.visualElement;
|
|
168
|
-
if (projection) {
|
|
169
|
-
projection.isAnimationBlocked = false;
|
|
170
|
-
}
|
|
171
|
-
this.panSession && this.panSession.end();
|
|
172
|
-
this.panSession = undefined;
|
|
173
|
-
const { dragPropagation } = this.getProps();
|
|
174
|
-
if (!dragPropagation && this.openDragLock) {
|
|
175
|
-
this.openDragLock();
|
|
176
|
-
this.openDragLock = null;
|
|
177
|
-
}
|
|
178
|
-
animationState && animationState.setActive("whileDrag", false);
|
|
179
|
-
}
|
|
180
|
-
updateAxis(axis, _point, offset) {
|
|
181
|
-
const { drag } = this.getProps();
|
|
182
|
-
// If we're not dragging this axis, do an early return.
|
|
183
|
-
if (!offset || !shouldDrag(axis, drag, this.currentDirection))
|
|
184
|
-
return;
|
|
185
|
-
const axisValue = this.getAxisMotionValue(axis);
|
|
186
|
-
let next = this.originPoint[axis] + offset[axis];
|
|
187
|
-
// Apply constraints
|
|
188
|
-
if (this.constraints && this.constraints[axis]) {
|
|
189
|
-
next = applyConstraints(next, this.constraints[axis], this.elastic[axis]);
|
|
190
|
-
}
|
|
191
|
-
axisValue.set(next);
|
|
192
|
-
}
|
|
193
|
-
resolveConstraints() {
|
|
194
|
-
const { dragConstraints, dragElastic } = this.getProps();
|
|
195
|
-
const layout = this.visualElement.projection &&
|
|
196
|
-
!this.visualElement.projection.layout
|
|
197
|
-
? this.visualElement.projection.measure(false)
|
|
198
|
-
: this.visualElement.projection?.layout;
|
|
199
|
-
const prevConstraints = this.constraints;
|
|
200
|
-
if (dragConstraints && isRefObject(dragConstraints)) {
|
|
201
|
-
if (!this.constraints) {
|
|
202
|
-
this.constraints = this.resolveRefConstraints();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
if (dragConstraints && layout) {
|
|
207
|
-
this.constraints = calcRelativeConstraints(layout.layoutBox, dragConstraints);
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
this.constraints = false;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
this.elastic = resolveDragElastic(dragElastic);
|
|
214
|
-
/**
|
|
215
|
-
* If we're outputting to external MotionValues, we want to rebase the measured constraints
|
|
216
|
-
* from viewport-relative to component-relative.
|
|
217
|
-
*/
|
|
218
|
-
if (prevConstraints !== this.constraints &&
|
|
219
|
-
layout &&
|
|
220
|
-
this.constraints &&
|
|
221
|
-
!this.hasMutatedConstraints) {
|
|
222
|
-
eachAxis((axis) => {
|
|
223
|
-
if (this.constraints !== false &&
|
|
224
|
-
this.getAxisMotionValue(axis)) {
|
|
225
|
-
this.constraints[axis] = rebaseAxisConstraints(layout.layoutBox[axis], this.constraints[axis]);
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
resolveRefConstraints() {
|
|
231
|
-
const { dragConstraints: constraints, onMeasureDragConstraints } = this.getProps();
|
|
232
|
-
if (!constraints || !isRefObject(constraints))
|
|
233
|
-
return false;
|
|
234
|
-
const constraintsElement = constraints.current;
|
|
235
|
-
invariant(constraintsElement !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");
|
|
236
|
-
const { projection } = this.visualElement;
|
|
237
|
-
// TODO
|
|
238
|
-
if (!projection || !projection.layout)
|
|
239
|
-
return false;
|
|
240
|
-
const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());
|
|
241
|
-
let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, constraintsBox);
|
|
242
|
-
/**
|
|
243
|
-
* If there's an onMeasureDragConstraints listener we call it and
|
|
244
|
-
* if different constraints are returned, set constraints to that
|
|
245
|
-
*/
|
|
246
|
-
if (onMeasureDragConstraints) {
|
|
247
|
-
const userConstraints = onMeasureDragConstraints(convertBoxToBoundingBox(measuredConstraints));
|
|
248
|
-
this.hasMutatedConstraints = !!userConstraints;
|
|
249
|
-
if (userConstraints) {
|
|
250
|
-
measuredConstraints = convertBoundingBoxToBox(userConstraints);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return measuredConstraints;
|
|
254
|
-
}
|
|
255
|
-
startAnimation(velocity) {
|
|
256
|
-
const { drag, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd, } = this.getProps();
|
|
257
|
-
const constraints = this.constraints || {};
|
|
258
|
-
const momentumAnimations = eachAxis((axis) => {
|
|
259
|
-
if (!shouldDrag(axis, drag, this.currentDirection)) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
let transition = (constraints && constraints[axis]) || {};
|
|
263
|
-
if (dragSnapToOrigin)
|
|
264
|
-
transition = { min: 0, max: 0 };
|
|
265
|
-
/**
|
|
266
|
-
* Overdamp the boundary spring if `dragElastic` is disabled. There's still a frame
|
|
267
|
-
* of spring animations so we should look into adding a disable spring option to `inertia`.
|
|
268
|
-
* We could do something here where we affect the `bounceStiffness` and `bounceDamping`
|
|
269
|
-
* using the value of `dragElastic`.
|
|
270
|
-
*/
|
|
271
|
-
const bounceStiffness = dragElastic ? 200 : 1000000;
|
|
272
|
-
const bounceDamping = dragElastic ? 40 : 10000000;
|
|
273
|
-
const inertia = {
|
|
274
|
-
type: "inertia",
|
|
275
|
-
velocity: dragMomentum ? velocity[axis] : 0,
|
|
276
|
-
bounceStiffness,
|
|
277
|
-
bounceDamping,
|
|
278
|
-
timeConstant: 750,
|
|
279
|
-
restDelta: 1,
|
|
280
|
-
restSpeed: 10,
|
|
281
|
-
...dragTransition,
|
|
282
|
-
...transition,
|
|
283
|
-
};
|
|
284
|
-
// If we're not animating on an externally-provided `MotionValue` we can use the
|
|
285
|
-
// component's animation controls which will handle interactions with whileHover (etc),
|
|
286
|
-
// otherwise we just have to animate the `MotionValue` itself.
|
|
287
|
-
return this.startAxisValueAnimation(axis, inertia);
|
|
288
|
-
});
|
|
289
|
-
// Run all animations and then resolve the new drag constraints.
|
|
290
|
-
return Promise.all(momentumAnimations).then(onDragTransitionEnd);
|
|
291
|
-
}
|
|
292
|
-
startAxisValueAnimation(axis, transition) {
|
|
293
|
-
const axisValue = this.getAxisMotionValue(axis);
|
|
294
|
-
addValueToWillChange(this.visualElement, axis);
|
|
295
|
-
return axisValue.start(animateMotionValue(axis, axisValue, 0, transition, this.visualElement, false));
|
|
296
|
-
}
|
|
297
|
-
stopAnimation() {
|
|
298
|
-
eachAxis((axis) => this.getAxisMotionValue(axis).stop());
|
|
299
|
-
}
|
|
300
|
-
pauseAnimation() {
|
|
301
|
-
eachAxis((axis) => this.getAxisMotionValue(axis).animation?.pause());
|
|
302
|
-
}
|
|
303
|
-
getAnimationState(axis) {
|
|
304
|
-
return this.getAxisMotionValue(axis).animation?.state;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Drag works differently depending on which props are provided.
|
|
308
|
-
*
|
|
309
|
-
* - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
|
|
310
|
-
* - Otherwise, we apply the delta to the x/y motion values.
|
|
311
|
-
*/
|
|
312
|
-
getAxisMotionValue(axis) {
|
|
313
|
-
const dragKey = `_drag${axis.toUpperCase()}`;
|
|
314
|
-
const props = this.visualElement.getProps();
|
|
315
|
-
const externalMotionValue = props[dragKey];
|
|
316
|
-
return externalMotionValue
|
|
317
|
-
? externalMotionValue
|
|
318
|
-
: this.visualElement.getValue(axis, (props.initial
|
|
319
|
-
? props.initial[axis]
|
|
320
|
-
: undefined) || 0);
|
|
321
|
-
}
|
|
322
|
-
snapToCursor(point) {
|
|
323
|
-
eachAxis((axis) => {
|
|
324
|
-
const { drag } = this.getProps();
|
|
325
|
-
// If we're not dragging this axis, do an early return.
|
|
326
|
-
if (!shouldDrag(axis, drag, this.currentDirection))
|
|
327
|
-
return;
|
|
328
|
-
const { projection } = this.visualElement;
|
|
329
|
-
const axisValue = this.getAxisMotionValue(axis);
|
|
330
|
-
if (projection && projection.layout) {
|
|
331
|
-
const { min, max } = projection.layout.layoutBox[axis];
|
|
332
|
-
axisValue.set(point[axis] - mixNumber(min, max, 0.5));
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* When the viewport resizes we want to check if the measured constraints
|
|
338
|
-
* have changed and, if so, reposition the element within those new constraints
|
|
339
|
-
* relative to where it was before the resize.
|
|
340
|
-
*/
|
|
341
|
-
scalePositionWithinConstraints() {
|
|
342
|
-
if (!this.visualElement.current)
|
|
343
|
-
return;
|
|
344
|
-
const { drag, dragConstraints } = this.getProps();
|
|
345
|
-
const { projection } = this.visualElement;
|
|
346
|
-
if (!isRefObject(dragConstraints) || !projection || !this.constraints)
|
|
347
|
-
return;
|
|
348
|
-
/**
|
|
349
|
-
* Stop current animations as there can be visual glitching if we try to do
|
|
350
|
-
* this mid-animation
|
|
351
|
-
*/
|
|
352
|
-
this.stopAnimation();
|
|
353
|
-
/**
|
|
354
|
-
* Record the relative position of the dragged element relative to the
|
|
355
|
-
* constraints box and save as a progress value.
|
|
356
|
-
*/
|
|
357
|
-
const boxProgress = { x: 0, y: 0 };
|
|
358
|
-
eachAxis((axis) => {
|
|
359
|
-
const axisValue = this.getAxisMotionValue(axis);
|
|
360
|
-
if (axisValue && this.constraints !== false) {
|
|
361
|
-
const latest = axisValue.get();
|
|
362
|
-
boxProgress[axis] = calcOrigin({ min: latest, max: latest }, this.constraints[axis]);
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
/**
|
|
366
|
-
* Update the layout of this element and resolve the latest drag constraints
|
|
367
|
-
*/
|
|
368
|
-
const { transformTemplate } = this.visualElement.getProps();
|
|
369
|
-
this.visualElement.current.style.transform = transformTemplate
|
|
370
|
-
? transformTemplate({}, "")
|
|
371
|
-
: "none";
|
|
372
|
-
projection.root && projection.root.updateScroll();
|
|
373
|
-
projection.updateLayout();
|
|
374
|
-
this.resolveConstraints();
|
|
375
|
-
/**
|
|
376
|
-
* For each axis, calculate the current progress of the layout axis
|
|
377
|
-
* within the new constraints.
|
|
378
|
-
*/
|
|
379
|
-
eachAxis((axis) => {
|
|
380
|
-
if (!shouldDrag(axis, drag, null))
|
|
381
|
-
return;
|
|
382
|
-
/**
|
|
383
|
-
* Calculate a new transform based on the previous box progress
|
|
384
|
-
*/
|
|
385
|
-
const axisValue = this.getAxisMotionValue(axis);
|
|
386
|
-
const { min, max } = this.constraints[axis];
|
|
387
|
-
axisValue.set(mixNumber(min, max, boxProgress[axis]));
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
addListeners() {
|
|
391
|
-
if (!this.visualElement.current)
|
|
392
|
-
return;
|
|
393
|
-
elementDragControls.set(this.visualElement, this);
|
|
394
|
-
const element = this.visualElement.current;
|
|
395
|
-
/**
|
|
396
|
-
* Attach a pointerdown event listener on this DOM element to initiate drag tracking.
|
|
397
|
-
*/
|
|
398
|
-
const stopPointerListener = addPointerEvent(element, "pointerdown", (event) => {
|
|
399
|
-
const { drag, dragListener = true } = this.getProps();
|
|
400
|
-
drag && dragListener && this.start(event);
|
|
401
|
-
});
|
|
402
|
-
const measureDragConstraints = () => {
|
|
403
|
-
const { dragConstraints } = this.getProps();
|
|
404
|
-
if (isRefObject(dragConstraints) && dragConstraints.current) {
|
|
405
|
-
this.constraints = this.resolveRefConstraints();
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
const { projection } = this.visualElement;
|
|
409
|
-
const stopMeasureLayoutListener = projection.addEventListener("measure", measureDragConstraints);
|
|
410
|
-
if (projection && !projection.layout) {
|
|
411
|
-
projection.root && projection.root.updateScroll();
|
|
412
|
-
projection.updateLayout();
|
|
413
|
-
}
|
|
414
|
-
frame.read(measureDragConstraints);
|
|
415
|
-
/**
|
|
416
|
-
* Attach a window resize listener to scale the draggable target within its defined
|
|
417
|
-
* constraints as the window resizes.
|
|
418
|
-
*/
|
|
419
|
-
const stopResizeListener = addDomEvent(window, "resize", () => this.scalePositionWithinConstraints());
|
|
420
|
-
/**
|
|
421
|
-
* If the element's layout changes, calculate the delta and apply that to
|
|
422
|
-
* the drag gesture's origin point.
|
|
423
|
-
*/
|
|
424
|
-
const stopLayoutUpdateListener = projection.addEventListener("didUpdate", (({ delta, hasLayoutChanged }) => {
|
|
425
|
-
if (this.isDragging && hasLayoutChanged) {
|
|
426
|
-
eachAxis((axis) => {
|
|
427
|
-
const motionValue = this.getAxisMotionValue(axis);
|
|
428
|
-
if (!motionValue)
|
|
429
|
-
return;
|
|
430
|
-
this.originPoint[axis] += delta[axis].translate;
|
|
431
|
-
motionValue.set(motionValue.get() + delta[axis].translate);
|
|
432
|
-
});
|
|
433
|
-
this.visualElement.render();
|
|
434
|
-
}
|
|
435
|
-
}));
|
|
436
|
-
return () => {
|
|
437
|
-
stopResizeListener();
|
|
438
|
-
stopPointerListener();
|
|
439
|
-
stopMeasureLayoutListener();
|
|
440
|
-
stopLayoutUpdateListener && stopLayoutUpdateListener();
|
|
441
|
-
};
|
|
442
|
-
}
|
|
443
|
-
getProps() {
|
|
444
|
-
const props = this.visualElement.getProps();
|
|
445
|
-
const { drag = false, dragDirectionLock = false, dragPropagation = false, dragConstraints = false, dragElastic = defaultElastic, dragMomentum = true, } = props;
|
|
446
|
-
return {
|
|
447
|
-
...props,
|
|
448
|
-
drag,
|
|
449
|
-
dragDirectionLock,
|
|
450
|
-
dragPropagation,
|
|
451
|
-
dragConstraints,
|
|
452
|
-
dragElastic,
|
|
453
|
-
dragMomentum,
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
function shouldDrag(direction, drag, currentDirection) {
|
|
458
|
-
return ((drag === true || drag === direction) &&
|
|
459
|
-
(currentDirection === null || currentDirection === direction));
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Based on an x/y offset determine the current drag direction. If both axis' offsets are lower
|
|
463
|
-
* than the provided threshold, return `null`.
|
|
464
|
-
*
|
|
465
|
-
* @param offset - The x/y offset from origin.
|
|
466
|
-
* @param lockThreshold - (Optional) - the minimum absolute offset before we can determine a drag direction.
|
|
467
|
-
*/
|
|
468
|
-
function getCurrentDirection(offset, lockThreshold = 10) {
|
|
469
|
-
let direction = null;
|
|
470
|
-
if (Math.abs(offset.y) > lockThreshold) {
|
|
471
|
-
direction = "y";
|
|
472
|
-
}
|
|
473
|
-
else if (Math.abs(offset.x) > lockThreshold) {
|
|
474
|
-
direction = "x";
|
|
475
|
-
}
|
|
476
|
-
return direction;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
export { VisualElementDragControls, elementDragControls };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Feature } from '../../motion/features/Feature.mjs';
|
|
2
|
-
import { VisualElementDragControls } from './VisualElementDragControls.mjs';
|
|
3
|
-
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
4
|
-
|
|
5
|
-
class DragGesture extends Feature {
|
|
6
|
-
constructor(node) {
|
|
7
|
-
super(node);
|
|
8
|
-
this.removeGroupControls = noop;
|
|
9
|
-
this.removeListeners = noop;
|
|
10
|
-
this.controls = new VisualElementDragControls(node);
|
|
11
|
-
}
|
|
12
|
-
mount() {
|
|
13
|
-
// If we've been provided a DragControls for manual control over the drag gesture,
|
|
14
|
-
// subscribe this component to it on mount.
|
|
15
|
-
const { dragControls } = this.node.getProps();
|
|
16
|
-
if (dragControls) {
|
|
17
|
-
this.removeGroupControls = dragControls.subscribe(this.controls);
|
|
18
|
-
}
|
|
19
|
-
this.removeListeners = this.controls.addListeners() || noop;
|
|
20
|
-
}
|
|
21
|
-
unmount() {
|
|
22
|
-
this.removeGroupControls();
|
|
23
|
-
this.removeListeners();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { DragGesture };
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { useConstant } from '../../utils/use-constant.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Can manually trigger a drag gesture on one or more `drag`-enabled `motion` components.
|
|
5
|
-
*
|
|
6
|
-
* ```jsx
|
|
7
|
-
* const dragControls = useDragControls()
|
|
8
|
-
*
|
|
9
|
-
* function startDrag(event) {
|
|
10
|
-
* dragControls.start(event, { snapToCursor: true })
|
|
11
|
-
* }
|
|
12
|
-
*
|
|
13
|
-
* return (
|
|
14
|
-
* <>
|
|
15
|
-
* <div onPointerDown={startDrag} />
|
|
16
|
-
* <motion.div drag="x" dragControls={dragControls} />
|
|
17
|
-
* </>
|
|
18
|
-
* )
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
class DragControls {
|
|
24
|
-
constructor() {
|
|
25
|
-
this.componentControls = new Set();
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Subscribe a component's internal `VisualElementDragControls` to the user-facing API.
|
|
29
|
-
*
|
|
30
|
-
* @internal
|
|
31
|
-
*/
|
|
32
|
-
subscribe(controls) {
|
|
33
|
-
this.componentControls.add(controls);
|
|
34
|
-
return () => this.componentControls.delete(controls);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Start a drag gesture on every `motion` component that has this set of drag controls
|
|
38
|
-
* passed into it via the `dragControls` prop.
|
|
39
|
-
*
|
|
40
|
-
* ```jsx
|
|
41
|
-
* dragControls.start(e, {
|
|
42
|
-
* snapToCursor: true
|
|
43
|
-
* })
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @param event - PointerEvent
|
|
47
|
-
* @param options - Options
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
start(event, options) {
|
|
52
|
-
this.componentControls.forEach((controls) => {
|
|
53
|
-
controls.start(event.nativeEvent || event, options);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const createDragControls = () => new DragControls();
|
|
58
|
-
/**
|
|
59
|
-
* Usually, dragging is initiated by pressing down on a `motion` component with a `drag` prop
|
|
60
|
-
* and moving it. For some use-cases, for instance clicking at an arbitrary point on a video scrubber, we
|
|
61
|
-
* might want to initiate that dragging from a different component than the draggable one.
|
|
62
|
-
*
|
|
63
|
-
* By creating a `dragControls` using the `useDragControls` hook, we can pass this into
|
|
64
|
-
* the draggable component's `dragControls` prop. It exposes a `start` method
|
|
65
|
-
* that can start dragging from pointer events on other components.
|
|
66
|
-
*
|
|
67
|
-
* ```jsx
|
|
68
|
-
* const dragControls = useDragControls()
|
|
69
|
-
*
|
|
70
|
-
* function startDrag(event) {
|
|
71
|
-
* dragControls.start(event, { snapToCursor: true })
|
|
72
|
-
* }
|
|
73
|
-
*
|
|
74
|
-
* return (
|
|
75
|
-
* <>
|
|
76
|
-
* <div onPointerDown={startDrag} />
|
|
77
|
-
* <motion.div drag="x" dragControls={dragControls} />
|
|
78
|
-
* </>
|
|
79
|
-
* )
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @public
|
|
83
|
-
*/
|
|
84
|
-
function useDragControls() {
|
|
85
|
-
return useConstant(createDragControls);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export { DragControls, useDragControls };
|