framer-motion 10.2.5 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dom-entry.js +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/{wrap-0d5542ae.js → wrap-462b1507.js} +79 -30
- package/dist/dom-entry.d.ts +4 -1
- package/dist/es/animation/GroupPlaybackControls.mjs +18 -6
- package/dist/es/animation/create-instant-animation.mjs +6 -2
- package/dist/es/animation/js/index.mjs +48 -19
- package/dist/es/animation/optimized-appear/handoff.mjs +1 -1
- package/dist/es/animation/waapi/create-accelerated-animation.mjs +7 -2
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +81 -32
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/projection.dev.js +80 -31
- package/dist/three-entry.d.ts +4 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -896,8 +896,11 @@ declare type Driver = (update: Update) => DriverControls;
|
|
|
896
896
|
* @public
|
|
897
897
|
*/
|
|
898
898
|
interface AnimationPlaybackControls {
|
|
899
|
-
|
|
899
|
+
time: number;
|
|
900
900
|
stop: () => void;
|
|
901
|
+
play: () => void;
|
|
902
|
+
pause: () => void;
|
|
903
|
+
then: (onResolve: VoidFunction, onReject?: VoidFunction) => Promise<void>;
|
|
901
904
|
}
|
|
902
905
|
interface VelocityOptions {
|
|
903
906
|
velocity?: number;
|
package/dist/projection.dev.js
CHANGED
|
@@ -1214,6 +1214,20 @@
|
|
|
1214
1214
|
return duration;
|
|
1215
1215
|
}
|
|
1216
1216
|
function animateValue({ autoplay = true, delay = 0, driver = frameloopDriver, keyframes: keyframes$1, type = "keyframes", repeat = 0, repeatDelay = 0, repeatType = "loop", onPlay, onStop, onComplete, onUpdate, ...options }) {
|
|
1217
|
+
let resolveFinishedPromise;
|
|
1218
|
+
let currentFinishedPromise;
|
|
1219
|
+
/**
|
|
1220
|
+
* Create a new finished Promise every time we enter the
|
|
1221
|
+
* finished state and resolve the old Promise. This is
|
|
1222
|
+
* WAAPI-compatible behaviour.
|
|
1223
|
+
*/
|
|
1224
|
+
const updateFinishedPromise = () => {
|
|
1225
|
+
currentFinishedPromise = new Promise((resolve) => {
|
|
1226
|
+
resolveFinishedPromise = resolve;
|
|
1227
|
+
});
|
|
1228
|
+
};
|
|
1229
|
+
// Create the first finished promise
|
|
1230
|
+
updateFinishedPromise();
|
|
1217
1231
|
let animationDriver;
|
|
1218
1232
|
const generatorFactory = types[type] || keyframes;
|
|
1219
1233
|
/**
|
|
@@ -1259,26 +1273,26 @@
|
|
|
1259
1273
|
resolvedDuration = calculatedDuration + repeatDelay;
|
|
1260
1274
|
totalDuration = resolvedDuration * (repeat + 1) - repeatDelay;
|
|
1261
1275
|
}
|
|
1262
|
-
let
|
|
1276
|
+
let time = 0;
|
|
1263
1277
|
const tick = (timestamp) => {
|
|
1264
1278
|
if (startTime === null)
|
|
1265
1279
|
return;
|
|
1266
1280
|
if (holdTime !== null) {
|
|
1267
|
-
|
|
1281
|
+
time = holdTime;
|
|
1268
1282
|
}
|
|
1269
1283
|
else {
|
|
1270
|
-
|
|
1284
|
+
time = timestamp - startTime;
|
|
1271
1285
|
}
|
|
1272
1286
|
// Rebase on delay
|
|
1273
|
-
|
|
1287
|
+
time = Math.max(time - delay, 0);
|
|
1274
1288
|
/**
|
|
1275
1289
|
* If this animation has finished, set the current time
|
|
1276
1290
|
* to the total duration.
|
|
1277
1291
|
*/
|
|
1278
1292
|
if (playState === "finished" && holdTime === null) {
|
|
1279
|
-
|
|
1293
|
+
time = totalDuration;
|
|
1280
1294
|
}
|
|
1281
|
-
let elapsed =
|
|
1295
|
+
let elapsed = time;
|
|
1282
1296
|
let frameGenerator = generator;
|
|
1283
1297
|
if (repeat) {
|
|
1284
1298
|
/**
|
|
@@ -1286,7 +1300,7 @@
|
|
|
1286
1300
|
* than duration we'll get values like 2.5 (midway through the
|
|
1287
1301
|
* third iteration)
|
|
1288
1302
|
*/
|
|
1289
|
-
const progress =
|
|
1303
|
+
const progress = time / resolvedDuration;
|
|
1290
1304
|
/**
|
|
1291
1305
|
* Get the current iteration (0 indexed). For instance the floor of
|
|
1292
1306
|
* 2.5 is 2.
|
|
@@ -1320,7 +1334,7 @@
|
|
|
1320
1334
|
frameGenerator = mirroredGenerator;
|
|
1321
1335
|
}
|
|
1322
1336
|
}
|
|
1323
|
-
const p =
|
|
1337
|
+
const p = time >= totalDuration
|
|
1324
1338
|
? repeatType === "reverse" && iterationIsOdd
|
|
1325
1339
|
? 0
|
|
1326
1340
|
: 1
|
|
@@ -1333,19 +1347,25 @@
|
|
|
1333
1347
|
onUpdate(mapNumbersToKeyframes ? mapNumbersToKeyframes(value) : value);
|
|
1334
1348
|
}
|
|
1335
1349
|
if (calculatedDuration !== null) {
|
|
1336
|
-
done =
|
|
1350
|
+
done = time >= totalDuration;
|
|
1337
1351
|
}
|
|
1338
1352
|
const isAnimationFinished = holdTime === null &&
|
|
1339
1353
|
(playState === "finished" || (playState === "running" && done));
|
|
1340
1354
|
if (isAnimationFinished) {
|
|
1341
|
-
|
|
1342
|
-
onComplete && onComplete();
|
|
1343
|
-
animationDriver && animationDriver.stop();
|
|
1355
|
+
finish();
|
|
1344
1356
|
}
|
|
1345
1357
|
return state;
|
|
1346
1358
|
};
|
|
1359
|
+
const finish = () => {
|
|
1360
|
+
animationDriver && animationDriver.stop();
|
|
1361
|
+
playState = "finished";
|
|
1362
|
+
onComplete && onComplete();
|
|
1363
|
+
resolveFinishedPromise();
|
|
1364
|
+
updateFinishedPromise();
|
|
1365
|
+
};
|
|
1347
1366
|
const play = () => {
|
|
1348
|
-
|
|
1367
|
+
if (!animationDriver)
|
|
1368
|
+
animationDriver = driver(tick);
|
|
1349
1369
|
const now = animationDriver.now();
|
|
1350
1370
|
onPlay && onPlay();
|
|
1351
1371
|
playState = "running";
|
|
@@ -1364,21 +1384,30 @@
|
|
|
1364
1384
|
play();
|
|
1365
1385
|
}
|
|
1366
1386
|
const controls = {
|
|
1367
|
-
|
|
1368
|
-
return
|
|
1387
|
+
then(resolve, reject) {
|
|
1388
|
+
return currentFinishedPromise.then(resolve, reject);
|
|
1369
1389
|
},
|
|
1370
|
-
|
|
1390
|
+
get time() {
|
|
1391
|
+
return millisecondsToSeconds(time);
|
|
1392
|
+
},
|
|
1393
|
+
set time(newTime) {
|
|
1394
|
+
const timeInMs = secondsToMilliseconds(newTime);
|
|
1371
1395
|
if (holdTime !== null || !animationDriver) {
|
|
1372
|
-
holdTime =
|
|
1396
|
+
holdTime = timeInMs;
|
|
1373
1397
|
}
|
|
1374
1398
|
else {
|
|
1375
|
-
startTime =
|
|
1376
|
-
animationDriver.now() - secondsToMilliseconds(newTime);
|
|
1399
|
+
startTime = animationDriver.now() - timeInMs;
|
|
1377
1400
|
}
|
|
1378
1401
|
},
|
|
1402
|
+
play,
|
|
1403
|
+
pause: () => {
|
|
1404
|
+
playState = "paused";
|
|
1405
|
+
holdTime = time;
|
|
1406
|
+
},
|
|
1379
1407
|
stop: () => {
|
|
1380
1408
|
onStop && onStop();
|
|
1381
1409
|
animationDriver && animationDriver.stop();
|
|
1410
|
+
animationDriver = undefined;
|
|
1382
1411
|
},
|
|
1383
1412
|
sample: (elapsed) => {
|
|
1384
1413
|
startTime = 0;
|
|
@@ -1477,12 +1506,17 @@
|
|
|
1477
1506
|
* Animation interrupt callback.
|
|
1478
1507
|
*/
|
|
1479
1508
|
return {
|
|
1480
|
-
|
|
1509
|
+
then(resolve, reject) {
|
|
1510
|
+
return animation.finished.then(resolve, reject);
|
|
1511
|
+
},
|
|
1512
|
+
get time() {
|
|
1481
1513
|
return millisecondsToSeconds(animation.currentTime || 0);
|
|
1482
1514
|
},
|
|
1483
|
-
set
|
|
1515
|
+
set time(newTime) {
|
|
1484
1516
|
animation.currentTime = secondsToMilliseconds(newTime);
|
|
1485
1517
|
},
|
|
1518
|
+
play: () => animation.play(),
|
|
1519
|
+
pause: () => animation.pause(),
|
|
1486
1520
|
stop: () => {
|
|
1487
1521
|
/**
|
|
1488
1522
|
* WAAPI doesn't natively have any interruption capabilities.
|
|
@@ -1510,8 +1544,11 @@
|
|
|
1510
1544
|
onUpdate && onUpdate(keyframes[keyframes.length - 1]);
|
|
1511
1545
|
onComplete && onComplete();
|
|
1512
1546
|
return {
|
|
1513
|
-
|
|
1514
|
-
|
|
1547
|
+
time: 0,
|
|
1548
|
+
play: (noop),
|
|
1549
|
+
pause: (noop),
|
|
1550
|
+
stop: (noop),
|
|
1551
|
+
then: Promise.resolve,
|
|
1515
1552
|
};
|
|
1516
1553
|
};
|
|
1517
1554
|
return delayBy
|
|
@@ -1973,7 +2010,7 @@
|
|
|
1973
2010
|
* This will be replaced by the build step with the latest version number.
|
|
1974
2011
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
1975
2012
|
*/
|
|
1976
|
-
this.version = "10.
|
|
2013
|
+
this.version = "10.3.0";
|
|
1977
2014
|
/**
|
|
1978
2015
|
* Duration, in milliseconds, since last updating frame.
|
|
1979
2016
|
*
|
|
@@ -2282,23 +2319,35 @@
|
|
|
2282
2319
|
constructor(animations) {
|
|
2283
2320
|
this.animations = animations.filter(Boolean);
|
|
2284
2321
|
}
|
|
2322
|
+
then(onResolve, onReject) {
|
|
2323
|
+
return Promise.all(this.animations).then(onResolve).catch(onReject);
|
|
2324
|
+
}
|
|
2285
2325
|
/**
|
|
2286
2326
|
* TODO: Filter out cancelled or stopped animations before returning
|
|
2287
2327
|
*/
|
|
2288
|
-
get
|
|
2289
|
-
return this.animations[0].
|
|
2328
|
+
get time() {
|
|
2329
|
+
return this.animations[0].time;
|
|
2290
2330
|
}
|
|
2291
2331
|
/**
|
|
2292
|
-
*
|
|
2332
|
+
* time assignment could reasonably run every frame, so
|
|
2293
2333
|
* we iterate using a normal loop to avoid function creation.
|
|
2294
2334
|
*/
|
|
2295
|
-
set
|
|
2335
|
+
set time(time) {
|
|
2296
2336
|
for (let i = 0; i < this.animations.length; i++) {
|
|
2297
|
-
this.animations[i].
|
|
2337
|
+
this.animations[i].time = time;
|
|
2298
2338
|
}
|
|
2299
2339
|
}
|
|
2340
|
+
runAll(methodName) {
|
|
2341
|
+
this.animations.forEach((controls) => controls[methodName]());
|
|
2342
|
+
}
|
|
2343
|
+
play() {
|
|
2344
|
+
this.runAll("play");
|
|
2345
|
+
}
|
|
2346
|
+
pause() {
|
|
2347
|
+
this.runAll("pause");
|
|
2348
|
+
}
|
|
2300
2349
|
stop() {
|
|
2301
|
-
this.
|
|
2350
|
+
this.runAll("stop");
|
|
2302
2351
|
}
|
|
2303
2352
|
}
|
|
2304
2353
|
|
|
@@ -5219,7 +5268,7 @@
|
|
|
5219
5268
|
* and warn against mismatches.
|
|
5220
5269
|
*/
|
|
5221
5270
|
{
|
|
5222
|
-
warnOnce(nextValue.version === "10.
|
|
5271
|
+
warnOnce(nextValue.version === "10.3.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.3.0 may not work as expected.`);
|
|
5223
5272
|
}
|
|
5224
5273
|
}
|
|
5225
5274
|
else if (isMotionValue(prevValue)) {
|
package/dist/three-entry.d.ts
CHANGED
|
@@ -856,8 +856,11 @@ interface CustomValueType {
|
|
|
856
856
|
* @public
|
|
857
857
|
*/
|
|
858
858
|
interface AnimationPlaybackControls {
|
|
859
|
-
|
|
859
|
+
time: number;
|
|
860
860
|
stop: () => void;
|
|
861
|
+
play: () => void;
|
|
862
|
+
pause: () => void;
|
|
863
|
+
then: (onResolve: VoidFunction, onReject?: VoidFunction) => Promise<void>;
|
|
861
864
|
}
|
|
862
865
|
/**
|
|
863
866
|
* @public
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "framer-motion",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.3.0",
|
|
4
4
|
"description": "A simple and powerful React and JavaScript animation library",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/es/index.mjs",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"bundlesize": [
|
|
86
86
|
{
|
|
87
87
|
"path": "./dist/size-rollup-motion.js",
|
|
88
|
-
"maxSize": "
|
|
88
|
+
"maxSize": "30.07 kB"
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
"path": "./dist/size-rollup-m.js",
|
|
@@ -93,11 +93,11 @@
|
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
"path": "./dist/size-rollup-dom-animation.js",
|
|
96
|
-
"maxSize": "14.
|
|
96
|
+
"maxSize": "14.68 kB"
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
99
|
"path": "./dist/size-rollup-dom-max.js",
|
|
100
|
-
"maxSize": "25.
|
|
100
|
+
"maxSize": "25.82 kB"
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
"path": "./dist/size-rollup-animate.js",
|
|
@@ -109,12 +109,12 @@
|
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
111
|
"path": "./dist/size-webpack-dom-animation.js",
|
|
112
|
-
"maxSize": "18.
|
|
112
|
+
"maxSize": "18.68 kB"
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"path": "./dist/size-webpack-dom-max.js",
|
|
116
|
-
"maxSize": "30.
|
|
116
|
+
"maxSize": "30.8 kB"
|
|
117
117
|
}
|
|
118
118
|
],
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "f464ee9f02ed31e4611b7316df6ea68018721031"
|
|
120
120
|
}
|