motion-start 0.0.1
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/LICENSE.md +21 -0
- package/README.md +39 -0
- package/package.json +64 -0
- package/src/animation/UseAnimatedState.svelte +86 -0
- package/src/animation/UseAnimation.svelte +61 -0
- package/src/animation/animate.ts +78 -0
- package/src/animation/animation-controls.ts +101 -0
- package/src/animation/types.ts +83 -0
- package/src/animation/use-animated-state.ts +1 -0
- package/src/animation/use-animation.ts +74 -0
- package/src/animation/utils/default-transitions.ts +70 -0
- package/src/animation/utils/easing.ts +55 -0
- package/src/animation/utils/is-animatable.ts +42 -0
- package/src/animation/utils/is-animation-controls.ts +17 -0
- package/src/animation/utils/is-keyframes-target.ts +17 -0
- package/src/animation/utils/transitions.ts +218 -0
- package/src/animation/utils/variant-resolvers.ts +15 -0
- package/src/components/AnimatePresence/AnimatePresence.svelte +180 -0
- package/src/components/AnimatePresence/PresenceChild/PresenceChild.svelte +78 -0
- package/src/components/AnimatePresence/PresenceChild/index.ts +7 -0
- package/src/components/AnimatePresence/PresenceChild/types.ts +10 -0
- package/src/components/AnimatePresence/index.ts +46 -0
- package/src/components/AnimatePresence/types.ts +79 -0
- package/src/components/AnimatePresence/use-presence.ts +90 -0
- package/src/components/AnimateSharedLayout/AnimateSharedLayout.svelte +239 -0
- package/src/components/AnimateSharedLayout/index.ts +11 -0
- package/src/components/AnimateSharedLayout/types.ts +111 -0
- package/src/components/AnimateSharedLayout/utils/batcher.ts +96 -0
- package/src/components/AnimateSharedLayout/utils/crossfader.ts +260 -0
- package/src/components/AnimateSharedLayout/utils/rotate.ts +48 -0
- package/src/components/AnimateSharedLayout/utils/stack.ts +160 -0
- package/src/components/LazyMotion/LazyMotion.svelte +82 -0
- package/src/components/LazyMotion/index.ts +42 -0
- package/src/components/LazyMotion/types.ts +58 -0
- package/src/components/MotionConfig/MotionConfig.svelte +56 -0
- package/src/components/MotionConfig/MotionConfigScaleCorrection.ts +47 -0
- package/src/components/MotionConfig/index.ts +20 -0
- package/src/components/MotionDiv.svelte +8 -0
- package/src/context/DOMcontext.ts +21 -0
- package/src/context/LayoutGroupContext.ts +13 -0
- package/src/context/LazyContext.ts +18 -0
- package/src/context/MotionConfigContext.ts +48 -0
- package/src/context/MotionContext/MotionContext.svelte +27 -0
- package/src/context/MotionContext/MotionContextProvider.svelte +22 -0
- package/src/context/MotionContext/UseCreateMotionContext.svelte +34 -0
- package/src/context/MotionContext/create.ts +1 -0
- package/src/context/MotionContext/index.ts +14 -0
- package/src/context/MotionContext/utils.ts +29 -0
- package/src/context/PresenceContext.ts +26 -0
- package/src/context/ScaleCorrectionProvider.svelte +27 -0
- package/src/context/SharedLayoutContext.ts +29 -0
- package/src/events/UseDomEvent.svelte +67 -0
- package/src/events/UsePointerEvent.svelte +76 -0
- package/src/events/event-info.ts +69 -0
- package/src/events/types.ts +15 -0
- package/src/events/use-dom-event.ts +48 -0
- package/src/events/use-pointer-event.ts +29 -0
- package/src/events/utils.ts +25 -0
- package/src/gestures/PanSession.ts +298 -0
- package/src/gestures/UseFocusGesture.svelte +31 -0
- package/src/gestures/UseGestures.svelte +17 -0
- package/src/gestures/UseHoverGesture.svelte +40 -0
- package/src/gestures/UsePanGesture.svelte +58 -0
- package/src/gestures/UseTapGesture.svelte +77 -0
- package/src/gestures/drag/UseDrag.svelte +55 -0
- package/src/gestures/drag/UseDragControls.svelte +145 -0
- package/src/gestures/drag/VisualElementDragControls.ts +632 -0
- package/src/gestures/drag/types.ts +307 -0
- package/src/gestures/drag/use-drag-controls.ts +148 -0
- package/src/gestures/drag/use-drag.ts +15 -0
- package/src/gestures/drag/utils/constraints.ts +157 -0
- package/src/gestures/drag/utils/lock.ts +69 -0
- package/src/gestures/types.ts +257 -0
- package/src/gestures/use-focus-gesture.ts +16 -0
- package/src/gestures/use-gestures.ts +2 -0
- package/src/gestures/use-hover-gesture.ts +10 -0
- package/src/gestures/use-pan-gesture.ts +22 -0
- package/src/gestures/use-tap-gesture.ts +14 -0
- package/src/gestures/utils/event-type.ts +24 -0
- package/src/gestures/utils/is-node-or-child.ts +31 -0
- package/src/index.ts +104 -0
- package/src/motion/Motion.svelte +246 -0
- package/src/motion/MotionSSR.svelte +244 -0
- package/src/motion/features/AnimationState.svelte +29 -0
- package/src/motion/features/Exit.svelte +32 -0
- package/src/motion/features/UseFeatures.svelte +39 -0
- package/src/motion/features/animations.ts +22 -0
- package/src/motion/features/definitions.ts +49 -0
- package/src/motion/features/drag.ts +24 -0
- package/src/motion/features/gestures.ts +24 -0
- package/src/motion/features/layout/Animate.svelte +314 -0
- package/src/motion/features/layout/Animate.ts +9 -0
- package/src/motion/features/layout/AnimateLayoutContextProvider.svelte +14 -0
- package/src/motion/features/layout/Measure.svelte +98 -0
- package/src/motion/features/layout/Measure.ts +9 -0
- package/src/motion/features/layout/MeasureContextProvider.svelte +32 -0
- package/src/motion/features/layout/index.ts +20 -0
- package/src/motion/features/layout/types.ts +71 -0
- package/src/motion/features/layout/utils.ts +40 -0
- package/src/motion/features/types.ts +53 -0
- package/src/motion/features/use-features.ts +16 -0
- package/src/motion/index.ts +64 -0
- package/src/motion/types.ts +278 -0
- package/src/motion/utils/UseLayoutId.svelte +18 -0
- package/src/motion/utils/UseVisualElement.svelte +104 -0
- package/src/motion/utils/UseVisualState.svelte +137 -0
- package/src/motion/utils/is-forced-motion-value.ts +23 -0
- package/src/motion/utils/make-renderless-component.ts +17 -0
- package/src/motion/utils/should-inhert-variant.ts +6 -0
- package/src/motion/utils/use-motion-ref.ts +41 -0
- package/src/motion/utils/use-visual-element.ts +13 -0
- package/src/motion/utils/use-visual-state.ts +24 -0
- package/src/motion/utils/valid-prop.ts +80 -0
- package/src/render/dom/M.svelte +16 -0
- package/src/render/dom/UseRender.svelte +37 -0
- package/src/render/dom/create-motion-class.ts +12 -0
- package/src/render/dom/create-visual-element.ts +22 -0
- package/src/render/dom/featureBundle.ts +22 -0
- package/src/render/dom/motion-minimal.ts +22 -0
- package/src/render/dom/motion-proxy.ts +107 -0
- package/src/render/dom/motion.ts +62 -0
- package/src/render/dom/projection/convert-to-relative.ts +40 -0
- package/src/render/dom/projection/default-scale-correctors.ts +138 -0
- package/src/render/dom/projection/measure.ts +28 -0
- package/src/render/dom/projection/relative-set.ts +27 -0
- package/src/render/dom/projection/scale-correction.ts +22 -0
- package/src/render/dom/projection/types.ts +13 -0
- package/src/render/dom/projection/utils.ts +69 -0
- package/src/render/dom/svg-visual-element.ts +114 -0
- package/src/render/dom/types.ts +32 -0
- package/src/render/dom/use-render.ts +11 -0
- package/src/render/dom/utils/UseInitialMotionProps.svelte +26 -0
- package/src/render/dom/utils/batch-layout.ts +77 -0
- package/src/render/dom/utils/camel-to-dash.ts +20 -0
- package/src/render/dom/utils/create-config.ts +33 -0
- package/src/render/dom/utils/css-variables-conversion.ts +121 -0
- package/src/render/dom/utils/filter-props.ts +55 -0
- package/src/render/dom/utils/is-css-variable.ts +18 -0
- package/src/render/dom/utils/is-svg-component.ts +41 -0
- package/src/render/dom/utils/parse-dom-variant.ts +26 -0
- package/src/render/dom/utils/unit-conversion.ts +258 -0
- package/src/render/dom/utils/use-html-props.ts +2 -0
- package/src/render/dom/utils/use-svg-props.ts +1 -0
- package/src/render/dom/value-types/animatable-none.ts +24 -0
- package/src/render/dom/value-types/defaults.ts +30 -0
- package/src/render/dom/value-types/dimensions.ts +27 -0
- package/src/render/dom/value-types/find.ts +31 -0
- package/src/render/dom/value-types/get-as-type.ts +21 -0
- package/src/render/dom/value-types/number.ts +83 -0
- package/src/render/dom/value-types/test.ts +17 -0
- package/src/render/dom/value-types/type-auto.ts +21 -0
- package/src/render/dom/value-types/type-int.ts +23 -0
- package/src/render/dom/value-types/types.ts +8 -0
- package/src/render/html/UseHTMLProps.svelte +33 -0
- package/src/render/html/UseInitialMotionValues.svelte +27 -0
- package/src/render/html/UseStyle.svelte +47 -0
- package/src/render/html/config-motion.ts +23 -0
- package/src/render/html/supported-elements.ts +10 -0
- package/src/render/html/types.ts +64 -0
- package/src/render/html/use-props.ts +14 -0
- package/src/render/html/utils/build-projection-transform.ts +53 -0
- package/src/render/html/utils/build-styles.ts +121 -0
- package/src/render/html/utils/build-transform.ts +79 -0
- package/src/render/html/utils/create-render-state.ts +18 -0
- package/src/render/html/utils/render.ts +22 -0
- package/src/render/html/utils/scrape-motion-values.ts +26 -0
- package/src/render/html/utils/transform.ts +51 -0
- package/src/render/html/visual-element.ts +129 -0
- package/src/render/index.ts +703 -0
- package/src/render/svg/UseSVGProps.svelte +34 -0
- package/src/render/svg/config-motion.ts +51 -0
- package/src/render/svg/lowercase-elements.ts +35 -0
- package/src/render/svg/supported-elements.ts +10 -0
- package/src/render/svg/types.ts +51 -0
- package/src/render/svg/use-props.ts +14 -0
- package/src/render/svg/utils/build-attrs.ts +58 -0
- package/src/render/svg/utils/camel-case-attrs.ts +27 -0
- package/src/render/svg/utils/create-render-state.ts +17 -0
- package/src/render/svg/utils/path.ts +49 -0
- package/src/render/svg/utils/render.ts +22 -0
- package/src/render/svg/utils/scrape-motion-values.ts +26 -0
- package/src/render/svg/utils/transform-origin.ts +30 -0
- package/src/render/svg/visual-element.ts +44 -0
- package/src/render/types.ts +148 -0
- package/src/render/utils/animation-state.ts +375 -0
- package/src/render/utils/animation.ts +167 -0
- package/src/render/utils/compare-by-depth.ts +18 -0
- package/src/render/utils/flat-tree.ts +35 -0
- package/src/render/utils/is-draggable.ts +17 -0
- package/src/render/utils/lifecycles.ts +172 -0
- package/src/render/utils/motion-values.ts +59 -0
- package/src/render/utils/projection.ts +38 -0
- package/src/render/utils/setters.ts +910 -0
- package/src/render/utils/state.ts +113 -0
- package/src/render/utils/types.ts +12 -0
- package/src/render/utils/variants.ts +76 -0
- package/src/types/geometry.ts +91 -0
- package/src/types.ts +1088 -0
- package/src/utils/UseUnmountEffect.svelte +11 -0
- package/src/utils/array.ts +18 -0
- package/src/utils/each-axis.ts +15 -0
- package/src/utils/errors.ts +22 -0
- package/src/utils/fix-process-env.ts +22 -0
- package/src/utils/geometry/delta-apply.ts +162 -0
- package/src/utils/geometry/delta-calc.ts +89 -0
- package/src/utils/geometry/index.ts +83 -0
- package/src/utils/is-browser.ts +12 -0
- package/src/utils/is-numerical-string.ts +15 -0
- package/src/utils/is-ref-object.ts +16 -0
- package/src/utils/noop.ts +15 -0
- package/src/utils/resolve-value.ts +23 -0
- package/src/utils/shallow-compare.ts +23 -0
- package/src/utils/subscription-manager.ts +49 -0
- package/src/utils/time-conversion.ts +18 -0
- package/src/utils/transform.ts +120 -0
- package/src/utils/use-constant.ts +23 -0
- package/src/utils/use-cycle.ts +78 -0
- package/src/utils/use-force-update.ts +7 -0
- package/src/utils/use-isomorphic-effect.ts +8 -0
- package/src/utils/use-reduced-motion.ts +70 -0
- package/src/utils/use-unmount-effect.ts +8 -0
- package/src/value/index.ts +409 -0
- package/src/value/scroll/use-element-scroll.ts +73 -0
- package/src/value/scroll/use-viewport-scroll.ts +81 -0
- package/src/value/scroll/utils.ts +76 -0
- package/src/value/use-combine-values.ts +53 -0
- package/src/value/use-motion-template.ts +57 -0
- package/src/value/use-motion-value.ts +27 -0
- package/src/value/use-spring.ts +84 -0
- package/src/value/use-transform.ts +216 -0
- package/src/value/use-velocity.ts +44 -0
- package/src/value/utils/is-motion-value.ts +15 -0
- package/src/value/utils/resolve-motion-value.ts +29 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { getContext, onMount } from "svelte";
|
|
6
|
+
import type { Writable } from "svelte/store";
|
|
7
|
+
import {
|
|
8
|
+
MotionConfigContext,
|
|
9
|
+
type MotionConfigContextObject,
|
|
10
|
+
} from "../context/MotionConfigContext";
|
|
11
|
+
import MotionContextProvider from "../context/MotionContext/MotionContextProvider.svelte";
|
|
12
|
+
import { UseCreateMotionContext } from "../context/MotionContext/create";
|
|
13
|
+
import ScaleCorrectionProvider from "../context/ScaleCorrectionProvider.svelte";
|
|
14
|
+
import { createDomVisualElement } from "../render/dom/create-visual-element.js";
|
|
15
|
+
import { UseRender } from "../render/dom/use-render.js";
|
|
16
|
+
import { htmlMotionConfig } from "../render/html/config-motion.js";
|
|
17
|
+
import { svgMotionConfig } from "../render/svg/config-motion.js";
|
|
18
|
+
import { UseFeatures } from "./features/use-features";
|
|
19
|
+
import type { MotionProps } from "./index.js";
|
|
20
|
+
import { useMotionRef } from "./utils/use-motion-ref.js";
|
|
21
|
+
import { UseVisualElement } from "./utils/use-visual-element";
|
|
22
|
+
import { UseVisualState } from "./utils/use-visual-state.js";
|
|
23
|
+
|
|
24
|
+
type $$Props = MotionProps & {
|
|
25
|
+
isSVG?: boolean;
|
|
26
|
+
update?: any;
|
|
27
|
+
forwardMotionProps?: boolean;
|
|
28
|
+
externalRef?: any;
|
|
29
|
+
targetEl?: any;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// component props
|
|
33
|
+
export let initial: $$Props["initial"] = undefined,
|
|
34
|
+
style: $$Props["style"] = undefined,
|
|
35
|
+
transformTemplate: $$Props["transformTemplate"] = undefined,
|
|
36
|
+
transformValues = undefined,
|
|
37
|
+
//AnimationProps
|
|
38
|
+
animate: $$Props["animate"] = undefined,
|
|
39
|
+
exit: $$Props["exit"] = undefined,
|
|
40
|
+
variants: $$Props["variants"] = undefined,
|
|
41
|
+
transition: $$Props["transition"] = undefined,
|
|
42
|
+
//VisualElementLifecycles
|
|
43
|
+
onViewportBoxUpdate: $$Props["onViewportBoxUpdate"] = undefined,
|
|
44
|
+
onBeforeLayoutMeasure: $$Props["onBeforeLayoutMeasure"] = undefined,
|
|
45
|
+
onLayoutMeasure: $$Props["onLayoutMeasure"] = undefined,
|
|
46
|
+
onUpdate: $$Props["onUpdate"] = undefined,
|
|
47
|
+
onAnimationStart: $$Props["onAnimationStart"] = undefined,
|
|
48
|
+
onAnimationComplete: $$Props["onAnimationComplete"] = undefined,
|
|
49
|
+
onLayoutAnimationComplete: $$Props["onLayoutAnimationComplete"] = undefined,
|
|
50
|
+
//GestureHandlers
|
|
51
|
+
// PanHandlers
|
|
52
|
+
onPan: $$Props["onPan"] = undefined,
|
|
53
|
+
onPanStart: $$Props["onPanStart"] = undefined,
|
|
54
|
+
onPanSessionStart: $$Props["onPanSessionStart"] = undefined,
|
|
55
|
+
onPanEnd: $$Props["onPanEnd"] = undefined,
|
|
56
|
+
// TapHandlers
|
|
57
|
+
onTap: $$Props["onTap"] = undefined,
|
|
58
|
+
onTapStart: $$Props["onTapStart"] = undefined,
|
|
59
|
+
onTapCancel: $$Props["onTapCancel"] = undefined,
|
|
60
|
+
whileTap: $$Props["whileTap"] = undefined,
|
|
61
|
+
//HoverHandlers
|
|
62
|
+
whileHover: $$Props["whileHover"] = undefined,
|
|
63
|
+
onHoverStart: $$Props["onHoverStart"] = undefined,
|
|
64
|
+
onHoverEnd: $$Props["onHoverEnd"] = undefined,
|
|
65
|
+
//FocusHandlers
|
|
66
|
+
whileFocus: $$Props["whileFocus"] = undefined,
|
|
67
|
+
//DraggableProps
|
|
68
|
+
drag: $$Props["drag"] = undefined,
|
|
69
|
+
whileDrag: $$Props["whileDrag"] = undefined,
|
|
70
|
+
dragDirectionLock: $$Props["dragDirectionLock"] = undefined,
|
|
71
|
+
dragPropagation: $$Props["dragPropagation"] = undefined,
|
|
72
|
+
dragConstraints: $$Props["dragConstraints"] = undefined,
|
|
73
|
+
dragElastic: $$Props["dragElastic"] = undefined,
|
|
74
|
+
dragMomentum: $$Props["dragMomentum"] = undefined,
|
|
75
|
+
dragTransition: $$Props["dragTransition"] = undefined,
|
|
76
|
+
dragControls: $$Props["dragControls"] = undefined,
|
|
77
|
+
dragListener: $$Props["dragListener"] = undefined,
|
|
78
|
+
onMeasureDragConstraints: $$Props["onMeasureDragConstraints"] = undefined,
|
|
79
|
+
_dragX: $$Props["_dragX"] = undefined,
|
|
80
|
+
_dragY: $$Props["_dragY"] = undefined,
|
|
81
|
+
//DragHandlers
|
|
82
|
+
onDragStart: $$Props["onDragStart"] = undefined,
|
|
83
|
+
onDragEnd: $$Props["onDragEnd"] = undefined,
|
|
84
|
+
onDrag: $$Props["onDrag"] = undefined,
|
|
85
|
+
onDirectionLock: $$Props["onDirectionLock"] = undefined,
|
|
86
|
+
onDragTransitionEnd: $$Props["onDragTransitionEnd"] = undefined,
|
|
87
|
+
// LayoutProps
|
|
88
|
+
layout: $$Props["layout"] = undefined,
|
|
89
|
+
layoutId: $$Props["layoutId"] = undefined,
|
|
90
|
+
//MotionAdvancedProps
|
|
91
|
+
custom: $$Props["custom"] = undefined,
|
|
92
|
+
inherit: $$Props["inherit"] = undefined,
|
|
93
|
+
// **internal***
|
|
94
|
+
isSVG: $$Props["isSVG"] = false,
|
|
95
|
+
update: $$Props["update"] = undefined,
|
|
96
|
+
forwardMotionProps: $$Props["forwardMotionProps"] = false,
|
|
97
|
+
externalRef: $$Props["externalRef"] = undefined,
|
|
98
|
+
targetEl: $$Props["targetEl"] = undefined;
|
|
99
|
+
|
|
100
|
+
$: motionProps = $$restProps; /*{
|
|
101
|
+
initial,
|
|
102
|
+
style,
|
|
103
|
+
transformTemplate,
|
|
104
|
+
transformValues,
|
|
105
|
+
//AnimationProps
|
|
106
|
+
animate,
|
|
107
|
+
exit,
|
|
108
|
+
variants,
|
|
109
|
+
transition,
|
|
110
|
+
//VisualElementLifecycles
|
|
111
|
+
onViewportBoxUpdate,
|
|
112
|
+
onBeforeLayoutMeasure,
|
|
113
|
+
onLayoutMeasure,
|
|
114
|
+
onUpdate,
|
|
115
|
+
onAnimationStart,
|
|
116
|
+
onAnimationComplete,
|
|
117
|
+
onLayoutAnimationComplete,
|
|
118
|
+
//GestureHandlers
|
|
119
|
+
// PanHandlers
|
|
120
|
+
onPan,
|
|
121
|
+
onPanStart,
|
|
122
|
+
onPanSessionStart,
|
|
123
|
+
onPanEnd,
|
|
124
|
+
// TapHandlers
|
|
125
|
+
onTap,
|
|
126
|
+
onTapStart,
|
|
127
|
+
onTapCancel,
|
|
128
|
+
whileTap,
|
|
129
|
+
//HoverHandlers
|
|
130
|
+
whileHover,
|
|
131
|
+
onHoverStart,
|
|
132
|
+
onHoverEnd,
|
|
133
|
+
//FocusHandlers
|
|
134
|
+
whileFocus,
|
|
135
|
+
//DraggableProps
|
|
136
|
+
drag,
|
|
137
|
+
whileDrag,
|
|
138
|
+
dragDirectionLock,
|
|
139
|
+
dragPropagation,
|
|
140
|
+
dragConstraints,
|
|
141
|
+
dragElastic,
|
|
142
|
+
dragMomentum,
|
|
143
|
+
dragTransition,
|
|
144
|
+
dragControls,
|
|
145
|
+
dragListener,
|
|
146
|
+
onMeasureDragConstraints,
|
|
147
|
+
_dragX,
|
|
148
|
+
_dragY,
|
|
149
|
+
//DragHandlers
|
|
150
|
+
onDragStart,
|
|
151
|
+
onDragEnd,
|
|
152
|
+
onDrag,
|
|
153
|
+
onDirectionLock,
|
|
154
|
+
onDragTransitionEnd,
|
|
155
|
+
// LayoutProps
|
|
156
|
+
layout,
|
|
157
|
+
layoutId,
|
|
158
|
+
//MotionAdvancedProps
|
|
159
|
+
custom,
|
|
160
|
+
inherit,
|
|
161
|
+
...(isSVG ? $$restProps : {}),
|
|
162
|
+
};*/
|
|
163
|
+
const isCustom = targetEl;
|
|
164
|
+
let Component = isSVG ? "SVG" : "DOM";
|
|
165
|
+
let createVisualElement = createDomVisualElement;
|
|
166
|
+
let visualStateConfig = isSVG ? svgMotionConfig : htmlMotionConfig;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* If a component is static, we only visually update it as a
|
|
170
|
+
* result of a React re-render, rather than any interactions or animations.
|
|
171
|
+
* If this component or any ancestor is static, we disable hardware acceleration
|
|
172
|
+
* and don't load any additional functionality.
|
|
173
|
+
*/
|
|
174
|
+
const a: Writable<MotionConfigContextObject> =
|
|
175
|
+
getContext(MotionConfigContext) || MotionConfigContext(isCustom);
|
|
176
|
+
$: ({ isStatic } = $a || {});
|
|
177
|
+
|
|
178
|
+
let mounted = false;
|
|
179
|
+
const setContext = (c, v) => {
|
|
180
|
+
c.visualElement = v;
|
|
181
|
+
return v;
|
|
182
|
+
};
|
|
183
|
+
onMount(() => (mounted = true));
|
|
184
|
+
</script>
|
|
185
|
+
|
|
186
|
+
<ScaleCorrectionProvider {isCustom}>
|
|
187
|
+
<UseCreateMotionContext
|
|
188
|
+
props={motionProps}
|
|
189
|
+
{isStatic}
|
|
190
|
+
let:value={context}
|
|
191
|
+
{isCustom}
|
|
192
|
+
>
|
|
193
|
+
<UseVisualState
|
|
194
|
+
config={visualStateConfig}
|
|
195
|
+
props={motionProps}
|
|
196
|
+
{isStatic}
|
|
197
|
+
{isCustom}
|
|
198
|
+
let:state={visualState}
|
|
199
|
+
>
|
|
200
|
+
<UseVisualElement
|
|
201
|
+
{Component}
|
|
202
|
+
{visualState}
|
|
203
|
+
{createVisualElement}
|
|
204
|
+
props={motionProps}
|
|
205
|
+
{isCustom}
|
|
206
|
+
let:visualElement
|
|
207
|
+
>
|
|
208
|
+
<UseFeatures
|
|
209
|
+
visualElement={setContext(context, visualElement)}
|
|
210
|
+
props={motionProps}
|
|
211
|
+
let:features={_features}
|
|
212
|
+
>
|
|
213
|
+
<MotionContextProvider value={context} {isCustom}>
|
|
214
|
+
<UseRender
|
|
215
|
+
{Component}
|
|
216
|
+
props={motionProps}
|
|
217
|
+
ref={useMotionRef(
|
|
218
|
+
visualState,
|
|
219
|
+
context.visualElement,
|
|
220
|
+
externalRef
|
|
221
|
+
)}
|
|
222
|
+
{visualState}
|
|
223
|
+
{isStatic}
|
|
224
|
+
{forwardMotionProps}
|
|
225
|
+
let:motion
|
|
226
|
+
let:props={renderProps}
|
|
227
|
+
>
|
|
228
|
+
<slot {motion} props={renderProps} />
|
|
229
|
+
</UseRender>
|
|
230
|
+
</MotionContextProvider>
|
|
231
|
+
|
|
232
|
+
{#if mounted}
|
|
233
|
+
{#each _features as feat (feat.key)}
|
|
234
|
+
<svelte:component
|
|
235
|
+
this={feat.Component}
|
|
236
|
+
props={feat.props}
|
|
237
|
+
visualElement={feat.visualElement}
|
|
238
|
+
{isCustom}
|
|
239
|
+
/>
|
|
240
|
+
{/each}
|
|
241
|
+
{/if}
|
|
242
|
+
</UseFeatures>
|
|
243
|
+
</UseVisualElement>
|
|
244
|
+
</UseVisualState>
|
|
245
|
+
</UseCreateMotionContext>
|
|
246
|
+
</ScaleCorrectionProvider>
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import type { MotionProps } from "./index.js";
|
|
6
|
+
import { MotionConfigContext, type MotionConfigContextObject } from "../context/MotionConfigContext";
|
|
7
|
+
import { UseVisualElement } from "./utils/use-visual-element";
|
|
8
|
+
import { UseFeatures } from "./features/use-features";
|
|
9
|
+
import MotionContextProvider from "../context/MotionContext/MotionContextProvider.svelte";
|
|
10
|
+
import { getContext, onMount } from "svelte";
|
|
11
|
+
import { UseRender } from "../render/dom/use-render.js";
|
|
12
|
+
import { createDomVisualElement } from "../render/dom/create-visual-element.js";
|
|
13
|
+
import { svgMotionConfig } from "../render/svg/config-motion.js";
|
|
14
|
+
import { htmlMotionConfig } from "../render/html/config-motion.js";
|
|
15
|
+
import { UseCreateMotionContext } from "../context/MotionContext/create";
|
|
16
|
+
import { UseVisualState } from "./utils/use-visual-state.js";
|
|
17
|
+
import { useMotionRef } from "./utils/use-motion-ref.js";
|
|
18
|
+
import ScaleCorrectionProvider from "../context/ScaleCorrectionProvider.svelte";
|
|
19
|
+
import { featureBundle } from "../render/dom/featureBundle.js";
|
|
20
|
+
import { loadFeatures } from "./features/definitions";
|
|
21
|
+
import type { Writable } from "svelte/store";
|
|
22
|
+
import type { VisualElement } from "../index.js";
|
|
23
|
+
|
|
24
|
+
type $$Props = MotionProps;
|
|
25
|
+
|
|
26
|
+
// component props
|
|
27
|
+
export let initial: $$Props['initial'] = undefined,
|
|
28
|
+
style: $$Props['style'] = undefined,
|
|
29
|
+
transformTemplate: $$Props['transformTemplate'] = undefined,
|
|
30
|
+
transformValues = undefined,
|
|
31
|
+
//AnimationProps
|
|
32
|
+
animate: $$Props['animate'] = undefined,
|
|
33
|
+
exit: $$Props['exit'] = undefined,
|
|
34
|
+
variants: $$Props['variants'] = undefined,
|
|
35
|
+
transition: $$Props['transition'] = undefined,
|
|
36
|
+
//VisualElementLifecycles
|
|
37
|
+
onViewportBoxUpdate: $$Props['onViewportBoxUpdate'] = undefined,
|
|
38
|
+
onBeforeLayoutMeasure: $$Props['onBeforeLayoutMeasure'] = undefined,
|
|
39
|
+
onLayoutMeasure: $$Props['onLayoutMeasure'] = undefined,
|
|
40
|
+
onUpdate: $$Props['onUpdate'] = undefined,
|
|
41
|
+
onAnimationStart: $$Props['onAnimationStart'] = undefined,
|
|
42
|
+
onAnimationComplete: $$Props['onAnimationComplete'] = undefined,
|
|
43
|
+
onLayoutAnimationComplete: $$Props['onLayoutAnimationComplete'] = undefined,
|
|
44
|
+
//GestureHandlers
|
|
45
|
+
// PanHandlers
|
|
46
|
+
onPan: $$Props['onPan'] = undefined,
|
|
47
|
+
onPanStart: $$Props['onPanStart'] = undefined,
|
|
48
|
+
onPanSessionStart: $$Props['onPanSessionStart'] = undefined,
|
|
49
|
+
onPanEnd: $$Props['onPanEnd'] = undefined,
|
|
50
|
+
// TapHandlers
|
|
51
|
+
onTap: $$Props['onTap'] = undefined,
|
|
52
|
+
onTapStart: $$Props['onTapStart'] = undefined,
|
|
53
|
+
onTapCancel: $$Props['onTapCancel'] = undefined,
|
|
54
|
+
whileTap: $$Props['whileTap'] = undefined,
|
|
55
|
+
//HoverHandlers
|
|
56
|
+
whileHover: $$Props['whileHover'] = undefined,
|
|
57
|
+
onHoverStart: $$Props['onHoverStart'] = undefined,
|
|
58
|
+
onHoverEnd: $$Props['onHoverEnd'] = undefined,
|
|
59
|
+
//FocusHandlers
|
|
60
|
+
whileFocus: $$Props['whileFocus'] = undefined,
|
|
61
|
+
//DraggableProps
|
|
62
|
+
drag: $$Props['drag'] = undefined,
|
|
63
|
+
whileDrag: $$Props['whileDrag'] = undefined,
|
|
64
|
+
dragDirectionLock: $$Props['dragDirectionLock'] = undefined,
|
|
65
|
+
dragPropagation: $$Props['dragPropagation'] = undefined,
|
|
66
|
+
dragConstraints: $$Props['dragConstraints'] = undefined,
|
|
67
|
+
dragElastic: $$Props['dragElastic'] = undefined,
|
|
68
|
+
dragMomentum: $$Props['dragMomentum'] = undefined,
|
|
69
|
+
dragTransition: $$Props['dragTransition'] = undefined,
|
|
70
|
+
dragControls: $$Props['dragControls'] = undefined,
|
|
71
|
+
dragListener: $$Props['dragListener'] = undefined,
|
|
72
|
+
onMeasureDragConstraints: $$Props['onMeasureDragConstraints'] = undefined,
|
|
73
|
+
_dragX: $$Props['_dragX'] = undefined,
|
|
74
|
+
_dragY: $$Props['_dragY'] = undefined,
|
|
75
|
+
//DragHandlers
|
|
76
|
+
onDragStart: $$Props['onDragStart'] = undefined,
|
|
77
|
+
onDragEnd: $$Props['onDragEnd'] = undefined,
|
|
78
|
+
onDrag: $$Props['onDrag'] = undefined,
|
|
79
|
+
onDirectionLock: $$Props['onDirectionLock'] = undefined,
|
|
80
|
+
onDragTransitionEnd: $$Props['onDragTransitionEnd'] = undefined,
|
|
81
|
+
// LayoutProps
|
|
82
|
+
layout: $$Props['layout'] = undefined,
|
|
83
|
+
layoutId: $$Props['layoutId'] = undefined,
|
|
84
|
+
//MotionAdvancedProps
|
|
85
|
+
custom: $$Props['custom'] = undefined,
|
|
86
|
+
inherit: $$Props['inherit'] = undefined,
|
|
87
|
+
|
|
88
|
+
// **internal***
|
|
89
|
+
isSVG = false,
|
|
90
|
+
update = undefined,
|
|
91
|
+
forwardMotionProps = false,
|
|
92
|
+
externalRef = undefined,
|
|
93
|
+
targetEl = undefined;
|
|
94
|
+
|
|
95
|
+
$: motionProps = $$restProps; /*{
|
|
96
|
+
initial,
|
|
97
|
+
style,
|
|
98
|
+
transformTemplate,
|
|
99
|
+
transformValues,
|
|
100
|
+
//AnimationProps
|
|
101
|
+
animate,
|
|
102
|
+
exit,
|
|
103
|
+
variants,
|
|
104
|
+
transition,
|
|
105
|
+
//VisualElementLifecycles
|
|
106
|
+
onViewportBoxUpdate,
|
|
107
|
+
onBeforeLayoutMeasure,
|
|
108
|
+
onLayoutMeasure,
|
|
109
|
+
onUpdate,
|
|
110
|
+
onAnimationStart,
|
|
111
|
+
onAnimationComplete,
|
|
112
|
+
onLayoutAnimationComplete,
|
|
113
|
+
//GestureHandlers
|
|
114
|
+
// PanHandlers
|
|
115
|
+
onPan,
|
|
116
|
+
onPanStart,
|
|
117
|
+
onPanSessionStart,
|
|
118
|
+
onPanEnd,
|
|
119
|
+
// TapHandlers
|
|
120
|
+
onTap,
|
|
121
|
+
onTapStart,
|
|
122
|
+
onTapCancel,
|
|
123
|
+
whileTap,
|
|
124
|
+
//HoverHandlers
|
|
125
|
+
whileHover,
|
|
126
|
+
onHoverStart,
|
|
127
|
+
onHoverEnd,
|
|
128
|
+
//FocusHandlers
|
|
129
|
+
whileFocus,
|
|
130
|
+
//DraggableProps
|
|
131
|
+
drag,
|
|
132
|
+
whileDrag,
|
|
133
|
+
dragDirectionLock,
|
|
134
|
+
dragPropagation,
|
|
135
|
+
dragConstraints,
|
|
136
|
+
dragElastic,
|
|
137
|
+
dragMomentum,
|
|
138
|
+
dragTransition,
|
|
139
|
+
dragControls,
|
|
140
|
+
dragListener,
|
|
141
|
+
onMeasureDragConstraints,
|
|
142
|
+
_dragX,
|
|
143
|
+
_dragY,
|
|
144
|
+
//DragHandlers
|
|
145
|
+
onDragStart,
|
|
146
|
+
onDragEnd,
|
|
147
|
+
onDrag,
|
|
148
|
+
onDirectionLock,
|
|
149
|
+
onDragTransitionEnd,
|
|
150
|
+
// LayoutProps
|
|
151
|
+
layout,
|
|
152
|
+
layoutId,
|
|
153
|
+
//MotionAdvancedProps
|
|
154
|
+
custom,
|
|
155
|
+
inherit,
|
|
156
|
+
...(isSVG ? $$restProps : {}),
|
|
157
|
+
};*/
|
|
158
|
+
//$: (allProps = {...motionProps,$$restProps});
|
|
159
|
+
|
|
160
|
+
// The SSR component needs to load this here
|
|
161
|
+
loadFeatures(featureBundle);
|
|
162
|
+
|
|
163
|
+
let Component = isSVG ? "SVG" : "DOM";
|
|
164
|
+
let isCustom = targetEl || false;
|
|
165
|
+
let createVisualElement = createDomVisualElement;
|
|
166
|
+
let visualStateConfig = isSVG ? svgMotionConfig : htmlMotionConfig;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* If a component is static, we only visually update it as a
|
|
170
|
+
* result of a React re-render, rather than any interactions or animations.
|
|
171
|
+
* If this component or any ancestor is static, we disable hardware acceleration
|
|
172
|
+
* and don't load any additional functionality.
|
|
173
|
+
*/
|
|
174
|
+
const a: Writable<MotionConfigContextObject> = getContext(MotionConfigContext) || MotionConfigContext(isCustom);
|
|
175
|
+
|
|
176
|
+
$: ({ isStatic } = $a || {});
|
|
177
|
+
let mounted = false;
|
|
178
|
+
const setContext = (c: any, v: VisualElement<any, any>) => {
|
|
179
|
+
c.visualElement = v;
|
|
180
|
+
return v;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
onMount(() => {
|
|
184
|
+
mounted = true;
|
|
185
|
+
});
|
|
186
|
+
</script>
|
|
187
|
+
|
|
188
|
+
<ScaleCorrectionProvider {isCustom}>
|
|
189
|
+
<UseCreateMotionContext props={motionProps} {isStatic} let:value={context}>
|
|
190
|
+
<UseVisualState
|
|
191
|
+
config={visualStateConfig}
|
|
192
|
+
props={motionProps}
|
|
193
|
+
{isStatic}
|
|
194
|
+
{isCustom}
|
|
195
|
+
let:state={visualState}
|
|
196
|
+
>
|
|
197
|
+
<UseVisualElement
|
|
198
|
+
{Component}
|
|
199
|
+
{visualState}
|
|
200
|
+
{createVisualElement}
|
|
201
|
+
props={motionProps}
|
|
202
|
+
{isCustom}
|
|
203
|
+
let:visualElement
|
|
204
|
+
>
|
|
205
|
+
<UseFeatures
|
|
206
|
+
visualElement={setContext(context, visualElement)}
|
|
207
|
+
props={motionProps}
|
|
208
|
+
let:features={_features}
|
|
209
|
+
>
|
|
210
|
+
<MotionContextProvider value={context} {isCustom}>
|
|
211
|
+
<UseRender
|
|
212
|
+
{Component}
|
|
213
|
+
props={motionProps}
|
|
214
|
+
ref={useMotionRef(
|
|
215
|
+
visualState,
|
|
216
|
+
context.visualElement,
|
|
217
|
+
externalRef
|
|
218
|
+
)}
|
|
219
|
+
{visualState}
|
|
220
|
+
{isStatic}
|
|
221
|
+
{forwardMotionProps}
|
|
222
|
+
let:motion
|
|
223
|
+
let:props={renderProps}
|
|
224
|
+
{targetEl}
|
|
225
|
+
>
|
|
226
|
+
<slot {motion} props={renderProps} />
|
|
227
|
+
</UseRender>
|
|
228
|
+
</MotionContextProvider>
|
|
229
|
+
|
|
230
|
+
{#if mounted}
|
|
231
|
+
{#each _features as feat (feat.key)}
|
|
232
|
+
<svelte:component
|
|
233
|
+
this={feat.Component}
|
|
234
|
+
props={feat.props}
|
|
235
|
+
visualElement={feat.visualElement}
|
|
236
|
+
{isCustom}
|
|
237
|
+
/>
|
|
238
|
+
{/each}
|
|
239
|
+
{/if}
|
|
240
|
+
</UseFeatures>
|
|
241
|
+
</UseVisualElement>
|
|
242
|
+
</UseVisualState>
|
|
243
|
+
</UseCreateMotionContext>
|
|
244
|
+
</ScaleCorrectionProvider>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { tick } from "svelte";
|
|
6
|
+
|
|
7
|
+
import { isAnimationControls } from "../../animation/utils/is-animation-controls.js";
|
|
8
|
+
import { createAnimationState } from "../../render/utils/animation-state.js";
|
|
9
|
+
export let visualElement, props;
|
|
10
|
+
|
|
11
|
+
let { animate } = props;
|
|
12
|
+
$: ({ animate } = props);
|
|
13
|
+
/**
|
|
14
|
+
* We dynamically generate the AnimationState manager as it contains a reference
|
|
15
|
+
* to the underlying animation library. We only want to load that if we load this,
|
|
16
|
+
* so people can optionally code split it out using the `m` component.
|
|
17
|
+
*/
|
|
18
|
+
$: {
|
|
19
|
+
visualElement.animationState =
|
|
20
|
+
visualElement.animationState || createAnimationState(visualElement);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Subscribe any provided AnimationControls to the component's VisualElement
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
$: if (isAnimationControls(animate)) {
|
|
27
|
+
tick().then(() => animate.subscribe(visualElement) /*, [animate]*/);
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { getContext } from "svelte";
|
|
6
|
+
import { usePresence } from "../../components/AnimatePresence/use-presence.js";
|
|
7
|
+
import { PresenceContext } from "../../context/PresenceContext.js";
|
|
8
|
+
import { AnimationType } from "../../render/utils/types.js";
|
|
9
|
+
|
|
10
|
+
export let props, visualElement, isCustom;
|
|
11
|
+
$: ({ custom } = props);
|
|
12
|
+
|
|
13
|
+
const presenceContext =
|
|
14
|
+
getContext(PresenceContext) || PresenceContext(isCustom);
|
|
15
|
+
const presence = usePresence(isCustom);
|
|
16
|
+
|
|
17
|
+
const effect = (pres) => {
|
|
18
|
+
const [isPresent, onExitComplete] = pres;
|
|
19
|
+
|
|
20
|
+
const animation = visualElement.animationState?.setActive(
|
|
21
|
+
AnimationType.Exit,
|
|
22
|
+
!isPresent,
|
|
23
|
+
{ custom: $presenceContext?.custom ?? custom }
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
!isPresent && animation?.then(onExitComplete);
|
|
27
|
+
return "";
|
|
28
|
+
};
|
|
29
|
+
$: effect($presence);
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<slot />
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import { featureDefinitions } from "./definitions";
|
|
6
|
+
const featureNames = Object.keys(featureDefinitions);
|
|
7
|
+
const numFeatures = featureNames.length;
|
|
8
|
+
export let visualElement, props;
|
|
9
|
+
|
|
10
|
+
let features = [];
|
|
11
|
+
|
|
12
|
+
// If this is a static component, or we're rendering on the server, we don't load
|
|
13
|
+
// any feature components
|
|
14
|
+
// Decide which features we should render and add them to the returned array
|
|
15
|
+
$: {
|
|
16
|
+
features = [];
|
|
17
|
+
for (let i = 0; i < numFeatures; i++) {
|
|
18
|
+
const name = featureNames[i];
|
|
19
|
+
const { isEnabled, Component } = featureDefinitions[name];
|
|
20
|
+
/**
|
|
21
|
+
* It might be possible in the future to use this moment to
|
|
22
|
+
* dynamically request functionality. In initial tests this
|
|
23
|
+
* was producing a lot of duplication amongst bundles.
|
|
24
|
+
*/
|
|
25
|
+
if (isEnabled(props) && Component) {
|
|
26
|
+
features.push({
|
|
27
|
+
Component: Component,
|
|
28
|
+
key: name,
|
|
29
|
+
props,
|
|
30
|
+
visualElement,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
{#if visualElement}
|
|
38
|
+
<slot {features} />
|
|
39
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { FeatureComponents } from "./types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import AnimationState from './AnimationState.svelte';
|
|
14
|
+
import Exit from './Exit.svelte';
|
|
15
|
+
/**
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
const animations = {
|
|
19
|
+
animation: AnimationState,
|
|
20
|
+
exit:Exit
|
|
21
|
+
} satisfies FeatureComponents
|
|
22
|
+
export { animations };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { FeatureComponents, FeatureDefinitions } from "./types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
var createDefinition = function (propNames) { return ({
|
|
14
|
+
isEnabled: function (props) { return propNames.some(function (name) { return !!props[name]; }); },
|
|
15
|
+
}); };
|
|
16
|
+
var featureDefinitions = {
|
|
17
|
+
measureLayout: createDefinition(["layout", "layoutId", "drag"]),
|
|
18
|
+
animation: createDefinition([
|
|
19
|
+
"animate",
|
|
20
|
+
"exit",
|
|
21
|
+
"variants",
|
|
22
|
+
"whileHover",
|
|
23
|
+
"whileTap",
|
|
24
|
+
"whileFocus",
|
|
25
|
+
"whileDrag",
|
|
26
|
+
]),
|
|
27
|
+
exit: createDefinition(["exit"]),
|
|
28
|
+
drag: createDefinition(["drag", "dragControls"]),
|
|
29
|
+
focus: createDefinition(["whileFocus"]),
|
|
30
|
+
hover: createDefinition(["whileHover", "onHoverStart", "onHoverEnd"]),
|
|
31
|
+
tap: createDefinition(["whileTap", "onTap", "onTapStart", "onTapCancel"]),
|
|
32
|
+
pan: createDefinition([
|
|
33
|
+
"onPan",
|
|
34
|
+
"onPanStart",
|
|
35
|
+
"onPanSessionStart",
|
|
36
|
+
"onPanEnd",
|
|
37
|
+
]),
|
|
38
|
+
layoutAnimation: createDefinition(["layout", "layoutId"]),
|
|
39
|
+
} satisfies FeatureDefinitions;
|
|
40
|
+
function loadFeatures(features: FeatureComponents): void {
|
|
41
|
+
for (var key in features) {
|
|
42
|
+
var Component = (features as any)[key];
|
|
43
|
+
if (Component !== null){
|
|
44
|
+
(featureDefinitions as any)[key].Component = Component;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { featureDefinitions, loadFeatures };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { FeatureComponents } from "./types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { UsePanGesture } from '../../gestures/use-pan-gesture.js';
|
|
14
|
+
import { UseDrag } from '../../gestures/drag/use-drag.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
const drag = {
|
|
20
|
+
pan: UsePanGesture,
|
|
21
|
+
drag: UseDrag
|
|
22
|
+
} satisfies FeatureComponents
|
|
23
|
+
|
|
24
|
+
export { drag };
|