motion-v 1.0.0-alpha.4 → 1.0.0-beta.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/dist/cjs/index.js +1063 -265
- package/dist/es/components/animate-presence/AnimatePresence.d.ts +1 -1
- package/dist/es/components/animate-presence/use-pop-layout.mjs +2 -1
- package/dist/es/components/motion/props.d.ts +0 -6
- package/dist/es/components/motion/props.mjs +1 -3
- package/dist/es/components/motion/use-motion-state.d.ts +41 -41
- package/dist/es/components/motion/use-motion-state.mjs +5 -3
- package/dist/es/components/motion/utils.mjs +4 -2
- package/dist/es/components/reorder/index.d.ts +160 -160
- package/dist/es/components/reorder/utils.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animate/index.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animate/single-value.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +4 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +2 -3
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/drivers/driver-frameloop.mjs +3 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +1 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +4 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/waapi/index.mjs +2 -9
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/generators/spring/index.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/interfaces/motion-value.mjs +3 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +3 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/sequence/create.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/easing/utils/map.mjs +1 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/projection/node/create-projection-node.mjs +4 -24
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/VisualElement.mjs +3 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/resize/handle-element.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/scroll/index.mjs +1 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/scroll/observe.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/scroll/track.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/viewport/index.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/utils/KeyframesResolver.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/utils/setters.mjs +2 -1
- package/dist/es/external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/utils/delay.mjs +2 -1
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/controls/BaseGroup.mjs +79 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/controls/Group.mjs +9 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/generators/utils/calc-duration.mjs +15 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs +17 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/generators/utils/is-generator.mjs +6 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/utils/get-value-transition.mjs +6 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +81 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/waapi/utils/attach-timeline.mjs +7 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/waapi/utils/easing.mjs +37 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/animation/waapi/utils/linear.mjs +13 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/batcher.mjs +64 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs +10 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/microtask.mjs +6 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/order.mjs +17 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/render-step.mjs +70 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/sync-time.mjs +22 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/drag/state/is-active.mjs +11 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/hover.mjs +30 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/press/index.mjs +74 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.mjs +13 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/press/utils/keyboard.mjs +32 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/press/utils/state.mjs +4 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/utils/capture-pointer.mjs +12 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/utils/is-node-or-child.mjs +12 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs +10 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/utils/setup.mjs +15 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/stats/buffer.mjs +7 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/is-bezier-definition.mjs +4 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/resolve-elements.mjs +17 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/supports/flags.mjs +6 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/supports/linear-easing.mjs +12 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/supports/memo.mjs +13 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +6 -0
- package/dist/es/external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/value/index.mjs +277 -0
- package/dist/es/external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/global-config.mjs +7 -0
- package/dist/es/features/gestures/drag/VisualElementDragControls.mjs +2 -1
- package/dist/es/features/gestures/hover/index.mjs +3 -1
- package/dist/es/features/gestures/in-view/index.mjs +2 -1
- package/dist/es/features/gestures/pan/PanSession.mjs +2 -1
- package/dist/es/features/gestures/pan/index.mjs +1 -1
- package/dist/es/features/gestures/press/index.mjs +3 -1
- package/dist/es/index.mjs +6 -1
- package/dist/es/state/create-visual-element.d.ts +2 -1
- package/dist/es/state/motion-state.mjs +1 -1
- package/dist/es/state/style.mjs +4 -0
- package/dist/es/state/utils.d.ts +2 -4
- package/dist/es/types/common.d.ts +1 -1
- package/dist/es/utils/use-animation-frame.mjs +2 -1
- package/dist/es/value/use-combine-values.mjs +3 -1
- package/dist/es/value/use-computed.mjs +2 -1
- package/dist/es/value/use-scroll.mjs +2 -1
- package/dist/es/value/use-spring.mjs +3 -1
- package/dist/es/value/use-time.mjs +2 -1
- package/dist/es/value/use-velocity.mjs +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import "../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
2
|
+
import { SubscriptionManager } from "../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/subscription-manager.mjs";
|
|
3
|
+
import { velocityPerSecond } from "../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/velocity-per-second.mjs";
|
|
4
|
+
import { warnOnce } from "../../../../../../motion-utils@12.5.0/external/motion-utils/dist/es/warn-once.mjs";
|
|
5
|
+
import { frame } from "../frameloop/frame.mjs";
|
|
6
|
+
import { time } from "../frameloop/sync-time.mjs";
|
|
7
|
+
const MAX_VELOCITY_DELTA = 30;
|
|
8
|
+
const isFloat = (value) => {
|
|
9
|
+
return !isNaN(parseFloat(value));
|
|
10
|
+
};
|
|
11
|
+
const collectMotionValues = {
|
|
12
|
+
current: void 0
|
|
13
|
+
};
|
|
14
|
+
class MotionValue {
|
|
15
|
+
/**
|
|
16
|
+
* @param init - The initiating value
|
|
17
|
+
* @param config - Optional configuration options
|
|
18
|
+
*
|
|
19
|
+
* - `transformer`: A function to transform incoming values with.
|
|
20
|
+
*/
|
|
21
|
+
constructor(init, options = {}) {
|
|
22
|
+
this.version = "12.5.0";
|
|
23
|
+
this.canTrackVelocity = null;
|
|
24
|
+
this.events = {};
|
|
25
|
+
this.updateAndNotify = (v, render = true) => {
|
|
26
|
+
const currentTime = time.now();
|
|
27
|
+
if (this.updatedAt !== currentTime) {
|
|
28
|
+
this.setPrevFrameValue();
|
|
29
|
+
}
|
|
30
|
+
this.prev = this.current;
|
|
31
|
+
this.setCurrent(v);
|
|
32
|
+
if (this.current !== this.prev && this.events.change) {
|
|
33
|
+
this.events.change.notify(this.current);
|
|
34
|
+
}
|
|
35
|
+
if (render && this.events.renderRequest) {
|
|
36
|
+
this.events.renderRequest.notify(this.current);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
this.hasAnimated = false;
|
|
40
|
+
this.setCurrent(init);
|
|
41
|
+
this.owner = options.owner;
|
|
42
|
+
}
|
|
43
|
+
setCurrent(current) {
|
|
44
|
+
this.current = current;
|
|
45
|
+
this.updatedAt = time.now();
|
|
46
|
+
if (this.canTrackVelocity === null && current !== void 0) {
|
|
47
|
+
this.canTrackVelocity = isFloat(this.current);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
setPrevFrameValue(prevFrameValue = this.current) {
|
|
51
|
+
this.prevFrameValue = prevFrameValue;
|
|
52
|
+
this.prevUpdatedAt = this.updatedAt;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Adds a function that will be notified when the `MotionValue` is updated.
|
|
56
|
+
*
|
|
57
|
+
* It returns a function that, when called, will cancel the subscription.
|
|
58
|
+
*
|
|
59
|
+
* When calling `onChange` inside a React component, it should be wrapped with the
|
|
60
|
+
* `useEffect` hook. As it returns an unsubscribe function, this should be returned
|
|
61
|
+
* from the `useEffect` function to ensure you don't add duplicate subscribers..
|
|
62
|
+
*
|
|
63
|
+
* ```jsx
|
|
64
|
+
* export const MyComponent = () => {
|
|
65
|
+
* const x = useMotionValue(0)
|
|
66
|
+
* const y = useMotionValue(0)
|
|
67
|
+
* const opacity = useMotionValue(1)
|
|
68
|
+
*
|
|
69
|
+
* useEffect(() => {
|
|
70
|
+
* function updateOpacity() {
|
|
71
|
+
* const maxXY = Math.max(x.get(), y.get())
|
|
72
|
+
* const newOpacity = transform(maxXY, [0, 100], [1, 0])
|
|
73
|
+
* opacity.set(newOpacity)
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* const unsubscribeX = x.on("change", updateOpacity)
|
|
77
|
+
* const unsubscribeY = y.on("change", updateOpacity)
|
|
78
|
+
*
|
|
79
|
+
* return () => {
|
|
80
|
+
* unsubscribeX()
|
|
81
|
+
* unsubscribeY()
|
|
82
|
+
* }
|
|
83
|
+
* }, [])
|
|
84
|
+
*
|
|
85
|
+
* return <motion.div style={{ x }} />
|
|
86
|
+
* }
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @param subscriber - A function that receives the latest value.
|
|
90
|
+
* @returns A function that, when called, will cancel this subscription.
|
|
91
|
+
*
|
|
92
|
+
* @deprecated
|
|
93
|
+
*/
|
|
94
|
+
onChange(subscription) {
|
|
95
|
+
if (process.env.NODE_ENV !== "production") {
|
|
96
|
+
warnOnce(false, `value.onChange(callback) is deprecated. Switch to value.on("change", callback).`);
|
|
97
|
+
}
|
|
98
|
+
return this.on("change", subscription);
|
|
99
|
+
}
|
|
100
|
+
on(eventName, callback) {
|
|
101
|
+
if (!this.events[eventName]) {
|
|
102
|
+
this.events[eventName] = new SubscriptionManager();
|
|
103
|
+
}
|
|
104
|
+
const unsubscribe = this.events[eventName].add(callback);
|
|
105
|
+
if (eventName === "change") {
|
|
106
|
+
return () => {
|
|
107
|
+
unsubscribe();
|
|
108
|
+
frame.read(() => {
|
|
109
|
+
if (!this.events.change.getSize()) {
|
|
110
|
+
this.stop();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return unsubscribe;
|
|
116
|
+
}
|
|
117
|
+
clearListeners() {
|
|
118
|
+
for (const eventManagers in this.events) {
|
|
119
|
+
this.events[eventManagers].clear();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Attaches a passive effect to the `MotionValue`.
|
|
124
|
+
*/
|
|
125
|
+
attach(passiveEffect, stopPassiveEffect) {
|
|
126
|
+
this.passiveEffect = passiveEffect;
|
|
127
|
+
this.stopPassiveEffect = stopPassiveEffect;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Sets the state of the `MotionValue`.
|
|
131
|
+
*
|
|
132
|
+
* @remarks
|
|
133
|
+
*
|
|
134
|
+
* ```jsx
|
|
135
|
+
* const x = useMotionValue(0)
|
|
136
|
+
* x.set(10)
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @param latest - Latest value to set.
|
|
140
|
+
* @param render - Whether to notify render subscribers. Defaults to `true`
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
set(v, render = true) {
|
|
145
|
+
if (!render || !this.passiveEffect) {
|
|
146
|
+
this.updateAndNotify(v, render);
|
|
147
|
+
} else {
|
|
148
|
+
this.passiveEffect(v, this.updateAndNotify);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
setWithVelocity(prev, current, delta) {
|
|
152
|
+
this.set(current);
|
|
153
|
+
this.prev = void 0;
|
|
154
|
+
this.prevFrameValue = prev;
|
|
155
|
+
this.prevUpdatedAt = this.updatedAt - delta;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Set the state of the `MotionValue`, stopping any active animations,
|
|
159
|
+
* effects, and resets velocity to `0`.
|
|
160
|
+
*/
|
|
161
|
+
jump(v, endAnimation = true) {
|
|
162
|
+
this.updateAndNotify(v);
|
|
163
|
+
this.prev = v;
|
|
164
|
+
this.prevUpdatedAt = this.prevFrameValue = void 0;
|
|
165
|
+
endAnimation && this.stop();
|
|
166
|
+
if (this.stopPassiveEffect)
|
|
167
|
+
this.stopPassiveEffect();
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Returns the latest state of `MotionValue`
|
|
171
|
+
*
|
|
172
|
+
* @returns - The latest state of `MotionValue`
|
|
173
|
+
*
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
get() {
|
|
177
|
+
if (collectMotionValues.current) {
|
|
178
|
+
collectMotionValues.current.push(this);
|
|
179
|
+
}
|
|
180
|
+
return this.current;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @public
|
|
184
|
+
*/
|
|
185
|
+
getPrevious() {
|
|
186
|
+
return this.prev;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Returns the latest velocity of `MotionValue`
|
|
190
|
+
*
|
|
191
|
+
* @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.
|
|
192
|
+
*
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
getVelocity() {
|
|
196
|
+
const currentTime = time.now();
|
|
197
|
+
if (!this.canTrackVelocity || this.prevFrameValue === void 0 || currentTime - this.updatedAt > MAX_VELOCITY_DELTA) {
|
|
198
|
+
return 0;
|
|
199
|
+
}
|
|
200
|
+
const delta = Math.min(this.updatedAt - this.prevUpdatedAt, MAX_VELOCITY_DELTA);
|
|
201
|
+
return velocityPerSecond(parseFloat(this.current) - parseFloat(this.prevFrameValue), delta);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Registers a new animation to control this `MotionValue`. Only one
|
|
205
|
+
* animation can drive a `MotionValue` at one time.
|
|
206
|
+
*
|
|
207
|
+
* ```jsx
|
|
208
|
+
* value.start()
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @param animation - A function that starts the provided animation
|
|
212
|
+
*/
|
|
213
|
+
start(startAnimation) {
|
|
214
|
+
this.stop();
|
|
215
|
+
return new Promise((resolve) => {
|
|
216
|
+
this.hasAnimated = true;
|
|
217
|
+
this.animation = startAnimation(resolve);
|
|
218
|
+
if (this.events.animationStart) {
|
|
219
|
+
this.events.animationStart.notify();
|
|
220
|
+
}
|
|
221
|
+
}).then(() => {
|
|
222
|
+
if (this.events.animationComplete) {
|
|
223
|
+
this.events.animationComplete.notify();
|
|
224
|
+
}
|
|
225
|
+
this.clearAnimation();
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Stop the currently active animation.
|
|
230
|
+
*
|
|
231
|
+
* @public
|
|
232
|
+
*/
|
|
233
|
+
stop() {
|
|
234
|
+
if (this.animation) {
|
|
235
|
+
this.animation.stop();
|
|
236
|
+
if (this.events.animationCancel) {
|
|
237
|
+
this.events.animationCancel.notify();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
this.clearAnimation();
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Returns `true` if this value is currently animating.
|
|
244
|
+
*
|
|
245
|
+
* @public
|
|
246
|
+
*/
|
|
247
|
+
isAnimating() {
|
|
248
|
+
return !!this.animation;
|
|
249
|
+
}
|
|
250
|
+
clearAnimation() {
|
|
251
|
+
delete this.animation;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Destroy and clean up subscribers to this `MotionValue`.
|
|
255
|
+
*
|
|
256
|
+
* The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically
|
|
257
|
+
* handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually
|
|
258
|
+
* created a `MotionValue` via the `motionValue` function.
|
|
259
|
+
*
|
|
260
|
+
* @public
|
|
261
|
+
*/
|
|
262
|
+
destroy() {
|
|
263
|
+
this.clearListeners();
|
|
264
|
+
this.stop();
|
|
265
|
+
if (this.stopPassiveEffect) {
|
|
266
|
+
this.stopPassiveEffect();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function motionValue(init, options) {
|
|
271
|
+
return new MotionValue(init, options);
|
|
272
|
+
}
|
|
273
|
+
export {
|
|
274
|
+
MotionValue,
|
|
275
|
+
collectMotionValues,
|
|
276
|
+
motionValue
|
|
277
|
+
};
|
|
@@ -17,7 +17,8 @@ import { mixNumber } from "../../../utils/mix/number.mjs";
|
|
|
17
17
|
import { invariant } from "hey-listen";
|
|
18
18
|
import { isPresent } from "../../../state/utils/is-present.mjs";
|
|
19
19
|
import { getContextWindow } from "../../../utils/get-context-window.mjs";
|
|
20
|
-
import { frame } from "motion-dom";
|
|
20
|
+
import { frame } from "../../../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
21
|
+
import "../../../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
21
22
|
const elementDragControls = /* @__PURE__ */ new WeakMap();
|
|
22
23
|
class VisualElementDragControls {
|
|
23
24
|
constructor(visualElement) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Feature } from "../../feature.mjs";
|
|
2
|
+
import { hover } from "../../../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/hover.mjs";
|
|
3
|
+
import "../../../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
4
|
+
import { frame } from "../../../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
2
5
|
import { extractEventInfo } from "../press/index.mjs";
|
|
3
|
-
import { hover, frame } from "motion-dom";
|
|
4
6
|
function handleHoverEvent(state, event, lifecycle) {
|
|
5
7
|
const props = state.options;
|
|
6
8
|
if (props.whileHover) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Feature } from "../../feature.mjs";
|
|
2
2
|
import { inView } from "../../../external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/viewport/index.mjs";
|
|
3
|
-
import { frame } from "motion-dom";
|
|
3
|
+
import { frame } from "../../../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
4
|
+
import "../../../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
4
5
|
function handleHoverEvent(state, entry, lifecycle) {
|
|
5
6
|
const props = state.options;
|
|
6
7
|
if (props.whileInView) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { addPointerEvent } from "../../../events/add-pointer-event.mjs";
|
|
2
2
|
import { extractEventInfo } from "../../../events/event-info.mjs";
|
|
3
3
|
import { distance2D } from "../../../external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/utils/distance.mjs";
|
|
4
|
+
import { frame, cancelFrame, frameData } from "../../../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
5
|
+
import "../../../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
4
6
|
import { pipe } from "../../../external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/utils/pipe.mjs";
|
|
5
7
|
import { secondsToMilliseconds, millisecondsToSeconds } from "../../../utils/time-conversion.mjs";
|
|
6
|
-
import { frame, cancelFrame, frameData } from "motion-dom";
|
|
7
8
|
import { isPrimaryPointer } from "../../../events/utils/is-primary-pointer.mjs";
|
|
8
9
|
class PanSession {
|
|
9
10
|
constructor(event, handlers, { transformPagePoint, contextWindow, dragSnapToOrigin = false } = {}) {
|
|
@@ -3,8 +3,8 @@ import { addPointerEvent } from "../../../events/add-pointer-event.mjs";
|
|
|
3
3
|
import { Feature } from "../../feature.mjs";
|
|
4
4
|
import { noop } from "../../../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/noop.mjs";
|
|
5
5
|
import "../../../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
6
|
+
import { frame } from "../../../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
6
7
|
import { getContextWindow } from "../../../utils/get-context-window.mjs";
|
|
7
|
-
import { frame } from "motion-dom";
|
|
8
8
|
function asyncHandler(handler) {
|
|
9
9
|
return (event, info) => {
|
|
10
10
|
if (handler) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Feature } from "../../feature.mjs";
|
|
2
|
-
import { press
|
|
2
|
+
import { press } from "../../../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/press/index.mjs";
|
|
3
|
+
import "../../../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
4
|
+
import { frame } from "../../../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
3
5
|
function extractEventInfo(event) {
|
|
4
6
|
return {
|
|
5
7
|
point: {
|
package/dist/es/index.mjs
CHANGED
|
@@ -8,7 +8,12 @@ import { domAnimation } from "./features/dom-animation.mjs";
|
|
|
8
8
|
import { default as default3 } from "./components/RowValue.vue.mjs";
|
|
9
9
|
import { default as default4 } from "./components/animate-presence/AnimatePresence.vue.mjs";
|
|
10
10
|
import { default as default5 } from "./components/motion-config/MotionConfig.vue.mjs";
|
|
11
|
-
import { MotionValue,
|
|
11
|
+
import { MotionValue, motionValue, motionValue as motionValue2 } from "./external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/value/index.mjs";
|
|
12
|
+
import { cancelFrame, frame, frameData } from "./external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
13
|
+
import { hover } from "./external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/hover.mjs";
|
|
14
|
+
import { isDragActive } from "./external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/drag/state/is-active.mjs";
|
|
15
|
+
import { press } from "./external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/gestures/press/index.mjs";
|
|
16
|
+
import { time } from "./external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/sync-time.mjs";
|
|
12
17
|
import { invariant } from "./external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
13
18
|
import { noop } from "./external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/noop.mjs";
|
|
14
19
|
import { progress } from "./external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/progress.mjs";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { AsTag } from '../types';
|
|
2
|
+
export declare function createVisualElement(Component: AsTag, options: any): any;
|
|
@@ -5,7 +5,7 @@ import { doneCallbacks } from "../components/presence.mjs";
|
|
|
5
5
|
import { isVariantLabels } from "./utils/is-variant-labels.mjs";
|
|
6
6
|
import { noop } from "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/noop.mjs";
|
|
7
7
|
import "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
8
|
-
import { frame, cancelFrame } from "motion-dom";
|
|
8
|
+
import { frame, cancelFrame } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
9
9
|
const mountedStates = /* @__PURE__ */ new WeakMap();
|
|
10
10
|
let id = 0;
|
|
11
11
|
const mountedLayoutIds = /* @__PURE__ */ new Set();
|
package/dist/es/state/style.mjs
CHANGED
|
@@ -44,12 +44,16 @@ function createStyles(keyframes) {
|
|
|
44
44
|
if (transforms.length) {
|
|
45
45
|
initialKeyframes.transform = buildTransformTemplate(transforms);
|
|
46
46
|
}
|
|
47
|
+
if (Object.keys(initialKeyframes).length === 0) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
47
50
|
return initialKeyframes;
|
|
48
51
|
}
|
|
49
52
|
const SVG_STYLE_TO_ATTRIBUTES = {
|
|
50
53
|
"fill": true,
|
|
51
54
|
"stroke": true,
|
|
52
55
|
"opacity": true,
|
|
56
|
+
"stroke-width": true,
|
|
53
57
|
"fill-opacity": true,
|
|
54
58
|
"stroke-opacity": true,
|
|
55
59
|
"stroke-linecap": true,
|
package/dist/es/state/utils.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { $Transition, Options } from '../types';
|
|
1
|
+
import { $Transition, AsTag, Options } from '../types';
|
|
2
2
|
import { Variant } from 'framer-motion';
|
|
3
|
-
import { IntrinsicElementAttributes } from 'vue';
|
|
4
3
|
export declare function resolveVariant(definition?: Options['animate'], variants?: Options['variants'], custom?: Options['custom']): Variant | undefined;
|
|
5
4
|
export declare function hasChanged(a: any, b: any): boolean;
|
|
6
5
|
export declare function shallowCompare(next: any[], prev: any[]): boolean;
|
|
@@ -10,10 +9,9 @@ export declare function getOptions(options: $Transition, key: string): $Transiti
|
|
|
10
9
|
export declare function isCssVar(name: string): boolean;
|
|
11
10
|
export declare const noopReturn: <V>(v: V) => V;
|
|
12
11
|
export declare function isNumber(value: any): boolean;
|
|
13
|
-
type ElementType = keyof IntrinsicElementAttributes;
|
|
14
12
|
export declare const svgElements: readonly ["animate", "circle", "defs", "desc", "ellipse", "g", "image", "line", "filter", "marker", "mask", "metadata", "path", "pattern", "polygon", "polyline", "rect", "stop", "svg", "switch", "symbol", "text", "tspan", "use", "view", "clipPath", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "foreignObject", "linearGradient", "radialGradient", "textPath"];
|
|
15
13
|
type UnionStringArray<T extends Readonly<string[]>> = T[number];
|
|
16
14
|
export type SVGElements = UnionStringArray<typeof svgElements>;
|
|
17
|
-
export declare function isSVGElement(as:
|
|
15
|
+
export declare function isSVGElement(as: AsTag): as is SVGElements;
|
|
18
16
|
export declare function isAnimateChanged(oldOptions: Options, newOptions: Options): boolean;
|
|
19
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Component, DefineComponent, ExtractPropTypes, ExtractPublicPropTypes, IntrinsicElementAttributes } from 'vue';
|
|
2
2
|
export type ComponentProps<T> = T extends DefineComponent<ExtractPropTypes<infer Props>, any, any> ? ExtractPublicPropTypes<Props> : never;
|
|
3
3
|
export type ElementType = keyof IntrinsicElementAttributes;
|
|
4
|
-
export type AsTag = keyof IntrinsicElementAttributes | (
|
|
4
|
+
export type AsTag = keyof IntrinsicElementAttributes | ({} & string) | Component;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { onBeforeUpdate, onUnmounted } from "vue";
|
|
2
|
-
import { frame, cancelFrame } from "motion-dom";
|
|
2
|
+
import { frame, cancelFrame } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
3
|
+
import "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
3
4
|
function useAnimationFrame(callback) {
|
|
4
5
|
let initialTimestamp = 0;
|
|
5
6
|
const provideTimeSinceStart = ({ timestamp, delta }) => {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { onUnmounted } from "vue";
|
|
2
|
-
import { motionValue
|
|
2
|
+
import { motionValue } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/value/index.mjs";
|
|
3
|
+
import "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
4
|
+
import { cancelFrame, frame } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
3
5
|
function useCombineMotionValues(combineValues) {
|
|
4
6
|
const value = motionValue(combineValues());
|
|
5
7
|
const updateValue = () => value.set(combineValues());
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCombineMotionValues } from "./use-combine-values.mjs";
|
|
2
|
-
import
|
|
2
|
+
import "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
3
|
+
import { collectMotionValues } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/value/index.mjs";
|
|
3
4
|
import { onBeforeUpdate } from "vue";
|
|
4
5
|
function useComputed(computed) {
|
|
5
6
|
collectMotionValues.current = [];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { onMounted, watch } from "vue";
|
|
2
2
|
import { warning } from "hey-listen";
|
|
3
3
|
import { scroll } from "../external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/render/dom/scroll/index.mjs";
|
|
4
|
-
import { motionValue } from "motion-dom";
|
|
4
|
+
import { motionValue } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/value/index.mjs";
|
|
5
|
+
import "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
5
6
|
function refWarning(name, ref) {
|
|
6
7
|
warning(
|
|
7
8
|
Boolean(!ref || ref.value),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { watch, isRef } from "vue";
|
|
2
2
|
import { animateValue } from "../external/.pnpm/framer-motion@12.5.0/external/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs";
|
|
3
|
-
import { motionValue
|
|
3
|
+
import { motionValue } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/value/index.mjs";
|
|
4
|
+
import "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
5
|
+
import { frame, frameData } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
4
6
|
import { isMotionValue } from "../utils/motion-value.mjs";
|
|
5
7
|
function toNumber(v) {
|
|
6
8
|
if (typeof v === "number")
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useAnimationFrame } from "../utils/use-animation-frame.mjs";
|
|
2
|
-
import { motionValue } from "motion-dom";
|
|
2
|
+
import { motionValue } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/value/index.mjs";
|
|
3
|
+
import "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
3
4
|
function useTime() {
|
|
4
5
|
const time = motionValue(0);
|
|
5
6
|
useAnimationFrame((t) => time.set(t));
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useMotionValueEvent } from "./use-motion-value-event.mjs";
|
|
2
|
-
import { motionValue
|
|
2
|
+
import { motionValue } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/value/index.mjs";
|
|
3
|
+
import "../external/.pnpm/motion-utils@12.5.0/external/motion-utils/dist/es/errors.mjs";
|
|
4
|
+
import { frame } from "../external/.pnpm/motion-dom@12.5.0/external/motion-dom/dist/es/frameloop/frame.mjs";
|
|
3
5
|
function useVelocity(value) {
|
|
4
6
|
const velocity = motionValue(value.getVelocity());
|
|
5
7
|
const updateVelocity = () => {
|