motion 11.11.13 → 11.11.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +21 -12
- package/README.md +19 -14
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/mini.js +555 -0
- package/dist/cjs/react-client.js +2 -2
- package/dist/cjs/react-mini.js +587 -0
- package/dist/cjs/react.js +14 -0
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/index.mjs +1 -1
- package/dist/es/motion/lib/mini.mjs +1 -0
- package/dist/es/motion/lib/react-mini.mjs +2 -0
- package/dist/motion.dev.js +2 -2
- package/dist/motion.js +1 -1
- package/lib/mini.js +2 -0
- package/lib/mini.js.map +1 -0
- package/lib/react-mini.js +3 -0
- package/lib/react-mini.js.map +1 -0
- package/mini/package.json +6 -0
- package/package.json +15 -3
- package/react/package.json +1 -1
- package/react-client/package.json +1 -1
- package/react-m/package.json +1 -1
- package/rollup.config.mjs +7 -1
- package/src/mini.ts +1 -0
- package/src/react-mini.ts +3 -0
- package/types/mini.d.ts +1 -0
- package/types/react-mini.d.ts +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,32 +1,41 @@
|
|
|
1
|
-
(node:
|
|
1
|
+
(node:28132) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
|
|
2
2
|
(Use `node --trace-warnings ...` to show where the warning was created)
|
|
3
3
|
[36m
|
|
4
4
|
[1mlib/index.js[22m → [1mdist/motion.dev.js[22m...[39m
|
|
5
|
-
[32mcreated [1mdist/motion.dev.js[22m in [
|
|
5
|
+
[32mcreated [1mdist/motion.dev.js[22m in [1m444ms[22m[39m
|
|
6
6
|
[36m
|
|
7
7
|
[1mlib/index.js[22m → [1mdist/motion.js[22m...[39m
|
|
8
|
-
[32mcreated [1mdist/motion.js[22m in [
|
|
8
|
+
[32mcreated [1mdist/motion.js[22m in [1m834ms[22m[39m
|
|
9
9
|
[36m
|
|
10
10
|
[1mlib/index.js[22m → [1mdist/cjs[22m...[39m
|
|
11
|
-
[32mcreated [1mdist/cjs[22m in [
|
|
11
|
+
[32mcreated [1mdist/cjs[22m in [1m222ms[22m[39m
|
|
12
12
|
[36m
|
|
13
13
|
[1mlib/react-client.js[22m → [1mdist/cjs[22m...[39m
|
|
14
|
-
[32mcreated [1mdist/cjs[22m in [
|
|
14
|
+
[32mcreated [1mdist/cjs[22m in [1m307ms[22m[39m
|
|
15
|
+
[36m
|
|
16
|
+
[1mlib/react.js[22m → [1mdist/cjs[22m...[39m
|
|
17
|
+
[32mcreated [1mdist/cjs[22m in [1m3ms[22m[39m
|
|
18
|
+
[36m
|
|
19
|
+
[1mlib/mini.js[22m → [1mdist/cjs[22m...[39m
|
|
20
|
+
[32mcreated [1mdist/cjs[22m in [1m22ms[22m[39m
|
|
21
|
+
[36m
|
|
22
|
+
[1mlib/react-mini.js[22m → [1mdist/cjs[22m...[39m
|
|
23
|
+
[32mcreated [1mdist/cjs[22m in [1m66ms[22m[39m
|
|
15
24
|
[36m
|
|
16
25
|
[1mlib/react-m.js[22m → [1mdist/cjs[22m...[39m
|
|
17
|
-
[32mcreated [1mdist/cjs[22m in [
|
|
26
|
+
[32mcreated [1mdist/cjs[22m in [1m98ms[22m[39m
|
|
18
27
|
[36m
|
|
19
|
-
[1mlib/index.js, lib/react.js, lib/react-client.js, lib/react-m.js[22m → [1mdist/es[22m...[39m
|
|
20
|
-
[32mcreated [1mdist/es[22m in [
|
|
28
|
+
[1mlib/index.js, lib/mini.js, lib/react.js, lib/react-mini.js, lib/react-client.js, lib/react-m.js[22m → [1mdist/es[22m...[39m
|
|
29
|
+
[32mcreated [1mdist/es[22m in [1m552ms[22m[39m
|
|
21
30
|
[36m
|
|
22
31
|
[1mtypes/index.d.ts[22m → [1mdist/index.d.ts[22m...[39m
|
|
23
|
-
[32mcreated [1mdist/index.d.ts[22m in [
|
|
32
|
+
[32mcreated [1mdist/index.d.ts[22m in [1m10ms[22m[39m
|
|
24
33
|
[36m
|
|
25
34
|
[1mtypes/react.d.ts[22m → [1mdist/react.d.ts[22m...[39m
|
|
26
|
-
[32mcreated [1mdist/react.d.ts[22m in [
|
|
35
|
+
[32mcreated [1mdist/react.d.ts[22m in [1m11ms[22m[39m
|
|
27
36
|
[36m
|
|
28
37
|
[1mtypes/react-m.d.ts[22m → [1mdist/react-m.d.ts[22m...[39m
|
|
29
|
-
[32mcreated [1mdist/react-m.d.ts[22m in [
|
|
38
|
+
[32mcreated [1mdist/react-m.d.ts[22m in [1m6ms[22m[39m
|
|
30
39
|
[36m
|
|
31
40
|
[1mtypes/react-client.d.ts[22m → [1mdist/react-client.d.ts[22m...[39m
|
|
32
|
-
[32mcreated [1mdist/react-client.d.ts[22m in [
|
|
41
|
+
[32mcreated [1mdist/react-client.d.ts[22m in [1m4ms[22m[39m
|
package/README.md
CHANGED
|
@@ -79,27 +79,32 @@ export function Component({ isVisible }) {
|
|
|
79
79
|
|
|
80
80
|
- Motion for React is MIT licensed.
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
## ✨ Sponsors
|
|
83
83
|
|
|
84
84
|
Motion is sustainable thanks to the kind support of its sponsors.
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
### Partners
|
|
87
87
|
|
|
88
88
|
Motion powers Framer animations, the web builder for creative pros. Design and ship your dream site. Zero code, maximum speed.
|
|
89
89
|
<br/>
|
|
90
90
|
|
|
91
|
-
<
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
</a>
|
|
101
|
-
</p>
|
|
91
|
+
<a href="https://www.framer.com?utm_source=motion-readme">
|
|
92
|
+
<img alt="Framer" src="https://github.com/user-attachments/assets/b0bc15ec-4c74-4b3c-8624-85fa7c7e78e9" width="300px" height="200px">
|
|
93
|
+
</a>
|
|
94
|
+
|
|
95
|
+
### Platinum
|
|
96
|
+
|
|
97
|
+
<a href="https://tailwindcss.com"><img alt="Tailwind" src="https://github.com/user-attachments/assets/c0496f09-b8ee-4bc4-85ab-83a071bbbdec" width="300px" height="200px"></a>
|
|
98
|
+
|
|
99
|
+
<a href="https://emilkowal.ski"><img alt="Emil Kowalski" src="https://github.com/user-attachments/assets/82ec7385-c8cf-4ce4-a9bf-3c38a76b7a4c" width="300px" height="200px"></a>
|
|
102
100
|
|
|
103
101
|
### Silver
|
|
104
102
|
|
|
105
|
-
|
|
103
|
+
<a href="https://www.frontend.fyi/?utm_source=motion"><img alt="Frontend.fyi" src="https://github.com/user-attachments/assets/07d23aa5-69db-44a0-849d-90177e6fc817" width="150px" height="100px"></a>
|
|
104
|
+
|
|
105
|
+
<a href="https://www.frontend.fyi/?utm_source=motion"><img alt="Statamic" src="https://github.com/user-attachments/assets/5d28f090-bdd9-4b31-b134-fb2b94ca636f" width="150px" height="100px"></a>
|
|
106
|
+
|
|
107
|
+
### Personal
|
|
108
|
+
|
|
109
|
+
- [Nusu](https://x.com/nusualabuga)
|
|
110
|
+
- [OlegWock](https://sinja.io)
|
package/dist/cjs/index.js
CHANGED
|
@@ -279,7 +279,7 @@ class MotionValue {
|
|
|
279
279
|
* This will be replaced by the build step with the latest version number.
|
|
280
280
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
281
281
|
*/
|
|
282
|
-
this.version = "11.11.
|
|
282
|
+
this.version = "11.11.15";
|
|
283
283
|
/**
|
|
284
284
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
285
285
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -4089,7 +4089,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
4089
4089
|
* and warn against mismatches.
|
|
4090
4090
|
*/
|
|
4091
4091
|
if (process.env.NODE_ENV === "development") {
|
|
4092
|
-
warnOnce(nextValue.version === "11.11.
|
|
4092
|
+
warnOnce(nextValue.version === "11.11.15", `Attempting to mix Motion versions ${nextValue.version} with 11.11.15 may not work as expected.`);
|
|
4093
4093
|
}
|
|
4094
4094
|
}
|
|
4095
4095
|
else if (isMotionValue(prevValue)) {
|
package/dist/cjs/mini.js
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function memo(callback) {
|
|
6
|
+
let result;
|
|
7
|
+
return () => {
|
|
8
|
+
if (result === undefined)
|
|
9
|
+
result = callback();
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const supportsScrollTimeline = memo(() => window.ScrollTimeline !== undefined);
|
|
15
|
+
|
|
16
|
+
class GroupPlaybackControls {
|
|
17
|
+
constructor(animations) {
|
|
18
|
+
// Bound to accomodate common `return animation.stop` pattern
|
|
19
|
+
this.stop = () => this.runAll("stop");
|
|
20
|
+
this.animations = animations.filter(Boolean);
|
|
21
|
+
}
|
|
22
|
+
then(onResolve, onReject) {
|
|
23
|
+
return Promise.all(this.animations).then(onResolve).catch(onReject);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* TODO: Filter out cancelled or stopped animations before returning
|
|
27
|
+
*/
|
|
28
|
+
getAll(propName) {
|
|
29
|
+
return this.animations[0][propName];
|
|
30
|
+
}
|
|
31
|
+
setAll(propName, newValue) {
|
|
32
|
+
for (let i = 0; i < this.animations.length; i++) {
|
|
33
|
+
this.animations[i][propName] = newValue;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
attachTimeline(timeline, fallback) {
|
|
37
|
+
const subscriptions = this.animations.map((animation) => {
|
|
38
|
+
if (supportsScrollTimeline() && animation.attachTimeline) {
|
|
39
|
+
return animation.attachTimeline(timeline);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return fallback(animation);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return () => {
|
|
46
|
+
subscriptions.forEach((cancel, i) => {
|
|
47
|
+
cancel && cancel();
|
|
48
|
+
this.animations[i].stop();
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
get time() {
|
|
53
|
+
return this.getAll("time");
|
|
54
|
+
}
|
|
55
|
+
set time(time) {
|
|
56
|
+
this.setAll("time", time);
|
|
57
|
+
}
|
|
58
|
+
get speed() {
|
|
59
|
+
return this.getAll("speed");
|
|
60
|
+
}
|
|
61
|
+
set speed(speed) {
|
|
62
|
+
this.setAll("speed", speed);
|
|
63
|
+
}
|
|
64
|
+
get startTime() {
|
|
65
|
+
return this.getAll("startTime");
|
|
66
|
+
}
|
|
67
|
+
get duration() {
|
|
68
|
+
let max = 0;
|
|
69
|
+
for (let i = 0; i < this.animations.length; i++) {
|
|
70
|
+
max = Math.max(max, this.animations[i].duration);
|
|
71
|
+
}
|
|
72
|
+
return max;
|
|
73
|
+
}
|
|
74
|
+
runAll(methodName) {
|
|
75
|
+
this.animations.forEach((controls) => controls[methodName]());
|
|
76
|
+
}
|
|
77
|
+
play() {
|
|
78
|
+
this.runAll("play");
|
|
79
|
+
}
|
|
80
|
+
pause() {
|
|
81
|
+
this.runAll("pause");
|
|
82
|
+
}
|
|
83
|
+
cancel() {
|
|
84
|
+
this.runAll("cancel");
|
|
85
|
+
}
|
|
86
|
+
complete() {
|
|
87
|
+
this.runAll("complete");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const noop = (any) => any;
|
|
92
|
+
|
|
93
|
+
let invariant = noop;
|
|
94
|
+
if (process.env.NODE_ENV !== "production") {
|
|
95
|
+
invariant = (check, message) => {
|
|
96
|
+
if (!check) {
|
|
97
|
+
throw new Error(message);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function resolveElements(elements, scope, selectorCache) {
|
|
103
|
+
var _a;
|
|
104
|
+
if (typeof elements === "string") {
|
|
105
|
+
let root = document;
|
|
106
|
+
if (scope) {
|
|
107
|
+
invariant(Boolean(scope.current), "Scope provided, but no element detected.");
|
|
108
|
+
root = scope.current;
|
|
109
|
+
}
|
|
110
|
+
if (selectorCache) {
|
|
111
|
+
(_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : (selectorCache[elements] = root.querySelectorAll(elements));
|
|
112
|
+
elements = selectorCache[elements];
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
elements = root.querySelectorAll(elements);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (elements instanceof Element) {
|
|
119
|
+
elements = [elements];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Return an empty array
|
|
123
|
+
*/
|
|
124
|
+
return Array.from(elements || []);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Converts seconds to milliseconds
|
|
129
|
+
*
|
|
130
|
+
* @param seconds - Time in seconds.
|
|
131
|
+
* @return milliseconds - Converted time in milliseconds.
|
|
132
|
+
*/
|
|
133
|
+
const secondsToMilliseconds = (seconds) => seconds * 1000;
|
|
134
|
+
const millisecondsToSeconds = (milliseconds) => milliseconds / 1000;
|
|
135
|
+
|
|
136
|
+
function getValueTransition(transition, key) {
|
|
137
|
+
return transition
|
|
138
|
+
? transition[key] ||
|
|
139
|
+
transition["default"] ||
|
|
140
|
+
transition
|
|
141
|
+
: undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
|
|
145
|
+
|
|
146
|
+
/*
|
|
147
|
+
Progress within given range
|
|
148
|
+
|
|
149
|
+
Given a lower limit and an upper limit, we return the progress
|
|
150
|
+
(expressed as a number 0-1) represented by the given value, and
|
|
151
|
+
limit that progress to within 0-1.
|
|
152
|
+
|
|
153
|
+
@param [number]: Lower limit
|
|
154
|
+
@param [number]: Upper limit
|
|
155
|
+
@param [number]: Value to find progress within given range
|
|
156
|
+
@return [number]: Progress of value within range as expressed 0-1
|
|
157
|
+
*/
|
|
158
|
+
const progress = (from, to, value) => {
|
|
159
|
+
const toFromDifference = to - from;
|
|
160
|
+
return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// Create a linear easing point for every 10 ms
|
|
164
|
+
const resolution = 10;
|
|
165
|
+
const generateLinearEasing = (easing, duration // as milliseconds
|
|
166
|
+
) => {
|
|
167
|
+
let points = "";
|
|
168
|
+
const numPoints = Math.max(Math.round(duration / resolution), 2);
|
|
169
|
+
for (let i = 0; i < numPoints; i++) {
|
|
170
|
+
points += easing(progress(0, numPoints - 1, i)) + ", ";
|
|
171
|
+
}
|
|
172
|
+
return `linear(${points.substring(0, points.length - 2)})`;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Add the ability for test suites to manually set support flags
|
|
177
|
+
* to better test more environments.
|
|
178
|
+
*/
|
|
179
|
+
const supportsFlags = {
|
|
180
|
+
linearEasing: undefined,
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
function memoSupports(callback, supportsFlag) {
|
|
184
|
+
const memoized = memo(callback);
|
|
185
|
+
return () => { var _a; return (_a = supportsFlags[supportsFlag]) !== null && _a !== void 0 ? _a : memoized(); };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const supportsLinearEasing = /*@__PURE__*/ memoSupports(() => {
|
|
189
|
+
try {
|
|
190
|
+
document
|
|
191
|
+
.createElement("div")
|
|
192
|
+
.animate({ opacity: 0 }, { easing: "linear(0, 1)" });
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
return true;
|
|
198
|
+
}, "linearEasing");
|
|
199
|
+
|
|
200
|
+
const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
|
|
201
|
+
const supportedWaapiEasing = {
|
|
202
|
+
linear: "linear",
|
|
203
|
+
ease: "ease",
|
|
204
|
+
easeIn: "ease-in",
|
|
205
|
+
easeOut: "ease-out",
|
|
206
|
+
easeInOut: "ease-in-out",
|
|
207
|
+
circIn: /*@__PURE__*/ cubicBezierAsString([0, 0.65, 0.55, 1]),
|
|
208
|
+
circOut: /*@__PURE__*/ cubicBezierAsString([0.55, 0, 1, 0.45]),
|
|
209
|
+
backIn: /*@__PURE__*/ cubicBezierAsString([0.31, 0.01, 0.66, -0.59]),
|
|
210
|
+
backOut: /*@__PURE__*/ cubicBezierAsString([0.33, 1.53, 0.69, 0.99]),
|
|
211
|
+
};
|
|
212
|
+
function mapEasingToNativeEasing(easing, duration) {
|
|
213
|
+
if (!easing) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
else if (typeof easing === "function" && supportsLinearEasing()) {
|
|
217
|
+
return generateLinearEasing(easing, duration);
|
|
218
|
+
}
|
|
219
|
+
else if (isBezierDefinition(easing)) {
|
|
220
|
+
return cubicBezierAsString(easing);
|
|
221
|
+
}
|
|
222
|
+
else if (Array.isArray(easing)) {
|
|
223
|
+
return easing.map((segmentEasing) => mapEasingToNativeEasing(segmentEasing, duration) ||
|
|
224
|
+
supportedWaapiEasing.easeOut);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
return supportedWaapiEasing[easing];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
|
|
232
|
+
const keyframeOptions = { [valueName]: keyframes };
|
|
233
|
+
if (times)
|
|
234
|
+
keyframeOptions.offset = times;
|
|
235
|
+
const easing = mapEasingToNativeEasing(ease, duration);
|
|
236
|
+
/**
|
|
237
|
+
* If this is an easing array, apply to keyframes, not animation as a whole
|
|
238
|
+
*/
|
|
239
|
+
if (Array.isArray(easing))
|
|
240
|
+
keyframeOptions.easing = easing;
|
|
241
|
+
return element.animate(keyframeOptions, {
|
|
242
|
+
delay,
|
|
243
|
+
duration,
|
|
244
|
+
easing: !Array.isArray(easing) ? easing : "linear",
|
|
245
|
+
fill: "both",
|
|
246
|
+
iterations: repeat + 1,
|
|
247
|
+
direction: repeatType === "reverse" ? "alternate" : "normal",
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Implement a practical max duration for keyframe generation
|
|
253
|
+
* to prevent infinite loops
|
|
254
|
+
*/
|
|
255
|
+
const maxGeneratorDuration = 20000;
|
|
256
|
+
function calcGeneratorDuration(generator) {
|
|
257
|
+
let duration = 0;
|
|
258
|
+
const timeStep = 50;
|
|
259
|
+
let state = generator.next(duration);
|
|
260
|
+
while (!state.done && duration < maxGeneratorDuration) {
|
|
261
|
+
duration += timeStep;
|
|
262
|
+
state = generator.next(duration);
|
|
263
|
+
}
|
|
264
|
+
return duration >= maxGeneratorDuration ? Infinity : duration;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Create a progress => progress easing function from a generator.
|
|
269
|
+
*/
|
|
270
|
+
function createGeneratorEasing(options, scale = 100, createGenerator) {
|
|
271
|
+
const generator = createGenerator({ ...options, keyframes: [0, scale] });
|
|
272
|
+
const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
273
|
+
return {
|
|
274
|
+
type: "keyframes",
|
|
275
|
+
ease: (progress) => generator.next(duration * progress).value / scale,
|
|
276
|
+
duration: millisecondsToSeconds(duration),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const createUnitType = (unit) => ({
|
|
281
|
+
test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
|
|
282
|
+
parse: parseFloat,
|
|
283
|
+
transform: (v) => `${v}${unit}`,
|
|
284
|
+
});
|
|
285
|
+
const px = /*@__PURE__*/ createUnitType("px");
|
|
286
|
+
|
|
287
|
+
const browserNumberValueTypes = {
|
|
288
|
+
// Border props
|
|
289
|
+
borderWidth: px,
|
|
290
|
+
borderTopWidth: px,
|
|
291
|
+
borderRightWidth: px,
|
|
292
|
+
borderBottomWidth: px,
|
|
293
|
+
borderLeftWidth: px,
|
|
294
|
+
borderRadius: px,
|
|
295
|
+
radius: px,
|
|
296
|
+
borderTopLeftRadius: px,
|
|
297
|
+
borderTopRightRadius: px,
|
|
298
|
+
borderBottomRightRadius: px,
|
|
299
|
+
borderBottomLeftRadius: px,
|
|
300
|
+
// Positioning props
|
|
301
|
+
width: px,
|
|
302
|
+
maxWidth: px,
|
|
303
|
+
height: px,
|
|
304
|
+
maxHeight: px,
|
|
305
|
+
top: px,
|
|
306
|
+
right: px,
|
|
307
|
+
bottom: px,
|
|
308
|
+
left: px,
|
|
309
|
+
// Spacing props
|
|
310
|
+
padding: px,
|
|
311
|
+
paddingTop: px,
|
|
312
|
+
paddingRight: px,
|
|
313
|
+
paddingBottom: px,
|
|
314
|
+
paddingLeft: px,
|
|
315
|
+
margin: px,
|
|
316
|
+
marginTop: px,
|
|
317
|
+
marginRight: px,
|
|
318
|
+
marginBottom: px,
|
|
319
|
+
marginLeft: px,
|
|
320
|
+
// Misc
|
|
321
|
+
backgroundPositionX: px,
|
|
322
|
+
backgroundPositionY: px,
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
function isGenerator(type) {
|
|
326
|
+
return typeof type === "function";
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function attachTimeline(animation, timeline) {
|
|
330
|
+
animation.timeline = timeline;
|
|
331
|
+
animation.onfinish = null;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const isNotNull = (value) => value !== null;
|
|
335
|
+
function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe) {
|
|
336
|
+
const resolvedKeyframes = keyframes.filter(isNotNull);
|
|
337
|
+
const index = repeat && repeatType !== "loop" && repeat % 2 === 1
|
|
338
|
+
? 0
|
|
339
|
+
: resolvedKeyframes.length - 1;
|
|
340
|
+
return !index || finalKeyframe === undefined
|
|
341
|
+
? resolvedKeyframes[index]
|
|
342
|
+
: finalKeyframe;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function setCSSVar(element, name, value) {
|
|
346
|
+
element.style.setProperty(`--${name}`, value);
|
|
347
|
+
}
|
|
348
|
+
function setStyle(element, name, value) {
|
|
349
|
+
element.style[name] = value;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const supportsPartialKeyframes = /*@__PURE__*/ memo(() => {
|
|
353
|
+
try {
|
|
354
|
+
document.createElement("div").animate({ opacity: [1] });
|
|
355
|
+
}
|
|
356
|
+
catch (e) {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
return true;
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
const supportsWaapi = /*@__PURE__*/ memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
|
|
363
|
+
|
|
364
|
+
const state = new WeakMap();
|
|
365
|
+
function hydrateKeyframes(valueName, keyframes, read) {
|
|
366
|
+
for (let i = 0; i < keyframes.length; i++) {
|
|
367
|
+
if (keyframes[i] === null) {
|
|
368
|
+
keyframes[i] = i === 0 ? read() : keyframes[i - 1];
|
|
369
|
+
}
|
|
370
|
+
if (typeof keyframes[i] === "number" &&
|
|
371
|
+
browserNumberValueTypes[valueName]) {
|
|
372
|
+
keyframes[i] = browserNumberValueTypes[valueName].transform(keyframes[i]);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (!supportsPartialKeyframes() && keyframes.length < 2) {
|
|
376
|
+
keyframes.unshift(read());
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const defaultEasing = "easeOut";
|
|
380
|
+
function getElementAnimationState(element) {
|
|
381
|
+
const animationState = state.get(element) || new Map();
|
|
382
|
+
state.set(element, animationState);
|
|
383
|
+
return state.get(element);
|
|
384
|
+
}
|
|
385
|
+
class NativeAnimation {
|
|
386
|
+
constructor(element, valueName, valueKeyframes, options) {
|
|
387
|
+
const isCSSVar = valueName.startsWith("--");
|
|
388
|
+
this.setValue = isCSSVar ? setCSSVar : setStyle;
|
|
389
|
+
this.options = options;
|
|
390
|
+
this.updateFinishedPromise();
|
|
391
|
+
invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "framer-motion"?`);
|
|
392
|
+
const existingAnimation = getElementAnimationState(element).get(valueName);
|
|
393
|
+
existingAnimation && existingAnimation.stop();
|
|
394
|
+
const readInitialKeyframe = () => {
|
|
395
|
+
return valueName.startsWith("--")
|
|
396
|
+
? element.style.getPropertyValue(valueName)
|
|
397
|
+
: window.getComputedStyle(element)[valueName];
|
|
398
|
+
};
|
|
399
|
+
if (!Array.isArray(valueKeyframes)) {
|
|
400
|
+
valueKeyframes = [valueKeyframes];
|
|
401
|
+
}
|
|
402
|
+
hydrateKeyframes(valueName, valueKeyframes, readInitialKeyframe);
|
|
403
|
+
if (isGenerator(options.type)) {
|
|
404
|
+
const generatorOptions = createGeneratorEasing(options, 100, options.type);
|
|
405
|
+
options.ease = supportsLinearEasing()
|
|
406
|
+
? generatorOptions.ease
|
|
407
|
+
: defaultEasing;
|
|
408
|
+
options.duration = secondsToMilliseconds(generatorOptions.duration);
|
|
409
|
+
options.type = "keyframes";
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
options.ease = options.ease || defaultEasing;
|
|
413
|
+
}
|
|
414
|
+
this.removeAnimation = () => { var _a; return (_a = state.get(element)) === null || _a === void 0 ? void 0 : _a.delete(valueName); };
|
|
415
|
+
const onFinish = () => {
|
|
416
|
+
this.setValue(element, valueName, getFinalKeyframe(valueKeyframes, this.options));
|
|
417
|
+
this.cancel();
|
|
418
|
+
this.resolveFinishedPromise();
|
|
419
|
+
};
|
|
420
|
+
if (!supportsWaapi()) {
|
|
421
|
+
onFinish();
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
this.animation = startWaapiAnimation(element, valueName, valueKeyframes, options);
|
|
425
|
+
if (options.autoplay === false) {
|
|
426
|
+
this.animation.pause();
|
|
427
|
+
}
|
|
428
|
+
this.animation.onfinish = onFinish;
|
|
429
|
+
if (this.pendingTimeline) {
|
|
430
|
+
attachTimeline(this.animation, this.pendingTimeline);
|
|
431
|
+
}
|
|
432
|
+
getElementAnimationState(element).set(valueName, this);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
get duration() {
|
|
436
|
+
return millisecondsToSeconds(this.options.duration || 300);
|
|
437
|
+
}
|
|
438
|
+
get time() {
|
|
439
|
+
var _a;
|
|
440
|
+
if (this.animation) {
|
|
441
|
+
return millisecondsToSeconds(((_a = this.animation) === null || _a === void 0 ? void 0 : _a.currentTime) || 0);
|
|
442
|
+
}
|
|
443
|
+
return 0;
|
|
444
|
+
}
|
|
445
|
+
set time(newTime) {
|
|
446
|
+
if (this.animation) {
|
|
447
|
+
this.animation.currentTime = secondsToMilliseconds(newTime);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
get speed() {
|
|
451
|
+
return this.animation ? this.animation.playbackRate : 1;
|
|
452
|
+
}
|
|
453
|
+
set speed(newSpeed) {
|
|
454
|
+
if (this.animation) {
|
|
455
|
+
this.animation.playbackRate = newSpeed;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
get state() {
|
|
459
|
+
return this.animation ? this.animation.playState : "finished";
|
|
460
|
+
}
|
|
461
|
+
get startTime() {
|
|
462
|
+
return this.animation ? this.animation.startTime : null;
|
|
463
|
+
}
|
|
464
|
+
play() {
|
|
465
|
+
if (this.state === "finished") {
|
|
466
|
+
this.updateFinishedPromise();
|
|
467
|
+
}
|
|
468
|
+
this.animation && this.animation.play();
|
|
469
|
+
}
|
|
470
|
+
pause() {
|
|
471
|
+
this.animation && this.animation.pause();
|
|
472
|
+
}
|
|
473
|
+
stop() {
|
|
474
|
+
if (!this.animation ||
|
|
475
|
+
this.state === "idle" ||
|
|
476
|
+
this.state === "finished") {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (this.animation.commitStyles) {
|
|
480
|
+
this.animation.commitStyles();
|
|
481
|
+
}
|
|
482
|
+
this.cancel();
|
|
483
|
+
}
|
|
484
|
+
complete() {
|
|
485
|
+
this.animation && this.animation.finish();
|
|
486
|
+
}
|
|
487
|
+
cancel() {
|
|
488
|
+
this.removeAnimation();
|
|
489
|
+
try {
|
|
490
|
+
this.animation && this.animation.cancel();
|
|
491
|
+
}
|
|
492
|
+
catch (e) { }
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Allows the returned animation to be awaited or promise-chained. Currently
|
|
496
|
+
* resolves when the animation finishes at all but in a future update could/should
|
|
497
|
+
* reject if its cancels.
|
|
498
|
+
*/
|
|
499
|
+
then(resolve, reject) {
|
|
500
|
+
return this.currentFinishedPromise.then(resolve, reject);
|
|
501
|
+
}
|
|
502
|
+
updateFinishedPromise() {
|
|
503
|
+
this.currentFinishedPromise = new Promise((resolve) => {
|
|
504
|
+
this.resolveFinishedPromise = resolve;
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
attachTimeline(timeline) {
|
|
508
|
+
if (!this.animation) {
|
|
509
|
+
this.pendingTimeline = timeline;
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
attachTimeline(this.animation, timeline);
|
|
513
|
+
}
|
|
514
|
+
return noop;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
519
|
+
const elements = resolveElements(elementOrSelector, scope);
|
|
520
|
+
const numElements = elements.length;
|
|
521
|
+
invariant(Boolean(numElements), "No valid element provided.");
|
|
522
|
+
const animations = [];
|
|
523
|
+
for (let i = 0; i < numElements; i++) {
|
|
524
|
+
const element = elements[i];
|
|
525
|
+
const elementTransition = { ...options };
|
|
526
|
+
/**
|
|
527
|
+
* Resolve stagger function if provided.
|
|
528
|
+
*/
|
|
529
|
+
if (typeof elementTransition.delay === "function") {
|
|
530
|
+
elementTransition.delay = elementTransition.delay(i, numElements);
|
|
531
|
+
}
|
|
532
|
+
for (const valueName in keyframes) {
|
|
533
|
+
const valueKeyframes = keyframes[valueName];
|
|
534
|
+
const valueOptions = {
|
|
535
|
+
...getValueTransition(options, valueName),
|
|
536
|
+
};
|
|
537
|
+
valueOptions.duration = valueOptions.duration
|
|
538
|
+
? secondsToMilliseconds(valueOptions.duration)
|
|
539
|
+
: valueOptions.duration;
|
|
540
|
+
valueOptions.delay = secondsToMilliseconds(valueOptions.delay || 0);
|
|
541
|
+
animations.push(new NativeAnimation(element, valueName, valueKeyframes, valueOptions));
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return animations;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const createScopedWaapiAnimate = (scope) => {
|
|
548
|
+
function scopedAnimate(elementOrSelector, keyframes, options) {
|
|
549
|
+
return new GroupPlaybackControls(animateElements(elementOrSelector, keyframes, options, scope));
|
|
550
|
+
}
|
|
551
|
+
return scopedAnimate;
|
|
552
|
+
};
|
|
553
|
+
const animateMini = /*@__PURE__*/ createScopedWaapiAnimate();
|
|
554
|
+
|
|
555
|
+
exports.animate = animateMini;
|
package/dist/cjs/react-client.js
CHANGED
|
@@ -3281,7 +3281,7 @@ class MotionValue {
|
|
|
3281
3281
|
* This will be replaced by the build step with the latest version number.
|
|
3282
3282
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
3283
3283
|
*/
|
|
3284
|
-
this.version = "11.11.
|
|
3284
|
+
this.version = "11.11.15";
|
|
3285
3285
|
/**
|
|
3286
3286
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
3287
3287
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -9024,7 +9024,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
9024
9024
|
* and warn against mismatches.
|
|
9025
9025
|
*/
|
|
9026
9026
|
if (process.env.NODE_ENV === "development") {
|
|
9027
|
-
warnOnce(nextValue.version === "11.11.
|
|
9027
|
+
warnOnce(nextValue.version === "11.11.15", `Attempting to mix Motion versions ${nextValue.version} with 11.11.15 may not work as expected.`);
|
|
9028
9028
|
}
|
|
9029
9029
|
}
|
|
9030
9030
|
else if (isMotionValue(prevValue)) {
|