framer-motion 7.5.4 → 7.6.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/index.js +25 -11
- package/dist/es/animation/utils/transitions.mjs +7 -6
- package/dist/es/index.mjs +1 -0
- package/dist/es/projection/node/create-projection-node.mjs +4 -3
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/utils/delay.mjs +16 -0
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +25 -11
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/projection.dev.js +24 -11
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/package.json +5 -5
package/dist/cjs/index.js
CHANGED
|
@@ -1958,12 +1958,25 @@ const instantAnimationState = {
|
|
|
1958
1958
|
current: false,
|
|
1959
1959
|
};
|
|
1960
1960
|
|
|
1961
|
+
function delay(callback, timeout) {
|
|
1962
|
+
const start = performance.now();
|
|
1963
|
+
const checkElapsed = ({ timestamp }) => {
|
|
1964
|
+
const elapsed = timestamp - start;
|
|
1965
|
+
if (elapsed >= timeout) {
|
|
1966
|
+
sync.cancelSync.read(checkElapsed);
|
|
1967
|
+
callback(elapsed - timeout);
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
sync__default["default"].read(checkElapsed, true);
|
|
1971
|
+
return () => sync.cancelSync.read(checkElapsed);
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1961
1974
|
/**
|
|
1962
1975
|
* Decide whether a transition is defined on a given Transition.
|
|
1963
1976
|
* This filters out orchestration options and returns true
|
|
1964
1977
|
* if any options are left.
|
|
1965
1978
|
*/
|
|
1966
|
-
function isTransitionDefined({ when, delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, ...transition }) {
|
|
1979
|
+
function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, ...transition }) {
|
|
1967
1980
|
return !!Object.keys(transition).length;
|
|
1968
1981
|
}
|
|
1969
1982
|
let legacyRepeatWarning = false;
|
|
@@ -2138,19 +2151,19 @@ function startAnimation(key, value, target, transition = {}) {
|
|
|
2138
2151
|
transition = { type: false };
|
|
2139
2152
|
}
|
|
2140
2153
|
return value.start((onComplete) => {
|
|
2141
|
-
let delayTimer;
|
|
2142
2154
|
let controls;
|
|
2143
2155
|
const animation = getAnimation(key, value, target, transition, onComplete);
|
|
2144
|
-
const
|
|
2156
|
+
const delayBy = getDelayFromTransition(transition, key);
|
|
2145
2157
|
const start = () => (controls = animation());
|
|
2146
|
-
|
|
2147
|
-
|
|
2158
|
+
let cancelDelay;
|
|
2159
|
+
if (delayBy) {
|
|
2160
|
+
cancelDelay = delay(start, secondsToMilliseconds(delayBy));
|
|
2148
2161
|
}
|
|
2149
2162
|
else {
|
|
2150
2163
|
start();
|
|
2151
2164
|
}
|
|
2152
2165
|
return () => {
|
|
2153
|
-
|
|
2166
|
+
cancelDelay && cancelDelay();
|
|
2154
2167
|
controls && controls.stop();
|
|
2155
2168
|
};
|
|
2156
2169
|
});
|
|
@@ -2245,7 +2258,7 @@ class MotionValue {
|
|
|
2245
2258
|
* This will be replaced by the build step with the latest version number.
|
|
2246
2259
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2247
2260
|
*/
|
|
2248
|
-
this.version = "7.
|
|
2261
|
+
this.version = "7.6.0";
|
|
2249
2262
|
/**
|
|
2250
2263
|
* Duration, in milliseconds, since last updating frame.
|
|
2251
2264
|
*
|
|
@@ -4223,7 +4236,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
4223
4236
|
* and warn against mismatches.
|
|
4224
4237
|
*/
|
|
4225
4238
|
if (process.env.NODE_ENV === "development") {
|
|
4226
|
-
warnOnce(nextValue.version === "7.
|
|
4239
|
+
warnOnce(nextValue.version === "7.6.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.0 may not work as expected.`);
|
|
4227
4240
|
}
|
|
4228
4241
|
}
|
|
4229
4242
|
else if (isMotionValue(prevValue)) {
|
|
@@ -5928,12 +5941,12 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
5928
5941
|
this.isLayoutDirty = true;
|
|
5929
5942
|
}
|
|
5930
5943
|
if (attachResizeListener) {
|
|
5931
|
-
let
|
|
5944
|
+
let cancelDelay;
|
|
5932
5945
|
const resizeUnblockUpdate = () => (this.root.updateBlockedByResize = false);
|
|
5933
5946
|
attachResizeListener(instance, () => {
|
|
5934
5947
|
this.root.updateBlockedByResize = true;
|
|
5935
|
-
|
|
5936
|
-
|
|
5948
|
+
cancelDelay && cancelDelay();
|
|
5949
|
+
cancelDelay = delay(resizeUnblockUpdate, 250);
|
|
5937
5950
|
if (globalProjectionState.hasAnimatedSinceResize) {
|
|
5938
5951
|
globalProjectionState.hasAnimatedSinceResize = false;
|
|
5939
5952
|
this.nodes.forEach(finishAnimation);
|
|
@@ -8434,6 +8447,7 @@ exports.checkTargetForNewValues = checkTargetForNewValues;
|
|
|
8434
8447
|
exports.createBox = createBox;
|
|
8435
8448
|
exports.createDomMotionComponent = createDomMotionComponent;
|
|
8436
8449
|
exports.createMotionComponent = createMotionComponent;
|
|
8450
|
+
exports.delay = delay;
|
|
8437
8451
|
exports.domAnimation = domAnimation;
|
|
8438
8452
|
exports.domMax = domMax;
|
|
8439
8453
|
exports.filterProps = filterProps;
|
|
@@ -7,13 +7,14 @@ import { warning } from 'hey-listen';
|
|
|
7
7
|
import { getAnimatableNone } from '../../render/dom/value-types/animatable-none.mjs';
|
|
8
8
|
import { instantAnimationState } from '../../utils/use-instant-transition-state.mjs';
|
|
9
9
|
import { resolveFinalValueInKeyframes } from '../../utils/resolve-value.mjs';
|
|
10
|
+
import { delay } from '../../utils/delay.mjs';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Decide whether a transition is defined on a given Transition.
|
|
13
14
|
* This filters out orchestration options and returns true
|
|
14
15
|
* if any options are left.
|
|
15
16
|
*/
|
|
16
|
-
function isTransitionDefined({ when, delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, ...transition }) {
|
|
17
|
+
function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, ...transition }) {
|
|
17
18
|
return !!Object.keys(transition).length;
|
|
18
19
|
}
|
|
19
20
|
let legacyRepeatWarning = false;
|
|
@@ -188,19 +189,19 @@ function startAnimation(key, value, target, transition = {}) {
|
|
|
188
189
|
transition = { type: false };
|
|
189
190
|
}
|
|
190
191
|
return value.start((onComplete) => {
|
|
191
|
-
let delayTimer;
|
|
192
192
|
let controls;
|
|
193
193
|
const animation = getAnimation(key, value, target, transition, onComplete);
|
|
194
|
-
const
|
|
194
|
+
const delayBy = getDelayFromTransition(transition, key);
|
|
195
195
|
const start = () => (controls = animation());
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
let cancelDelay;
|
|
197
|
+
if (delayBy) {
|
|
198
|
+
cancelDelay = delay(start, secondsToMilliseconds(delayBy));
|
|
198
199
|
}
|
|
199
200
|
else {
|
|
200
201
|
start();
|
|
201
202
|
}
|
|
202
203
|
return () => {
|
|
203
|
-
|
|
204
|
+
cancelDelay && cancelDelay();
|
|
204
205
|
controls && controls.stop();
|
|
205
206
|
};
|
|
206
207
|
});
|
package/dist/es/index.mjs
CHANGED
|
@@ -42,6 +42,7 @@ export { addScaleCorrector } from './projection/styles/scale-correction.mjs';
|
|
|
42
42
|
export { useInstantTransition } from './utils/use-instant-transition.mjs';
|
|
43
43
|
export { useInstantLayoutTransition } from './projection/use-instant-layout-transition.mjs';
|
|
44
44
|
export { useResetProjection } from './projection/use-reset-projection.mjs';
|
|
45
|
+
export { delay } from './utils/delay.mjs';
|
|
45
46
|
export { MotionContext, useVisualElementContext } from './context/MotionContext/index.mjs';
|
|
46
47
|
export { MotionConfigContext } from './context/MotionConfigContext.mjs';
|
|
47
48
|
export { PresenceContext } from './context/PresenceContext.mjs';
|
|
@@ -18,6 +18,7 @@ import { hasTransform, hasScale, has2DTranslate } from '../utils/has-transform.m
|
|
|
18
18
|
import { FlatTree } from '../../render/utils/flat-tree.mjs';
|
|
19
19
|
import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
|
|
20
20
|
import { globalProjectionState } from './state.mjs';
|
|
21
|
+
import { delay } from '../../utils/delay.mjs';
|
|
21
22
|
|
|
22
23
|
const transformAxes = ["", "X", "Y", "Z"];
|
|
23
24
|
/**
|
|
@@ -160,12 +161,12 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
160
161
|
this.isLayoutDirty = true;
|
|
161
162
|
}
|
|
162
163
|
if (attachResizeListener) {
|
|
163
|
-
let
|
|
164
|
+
let cancelDelay;
|
|
164
165
|
const resizeUnblockUpdate = () => (this.root.updateBlockedByResize = false);
|
|
165
166
|
attachResizeListener(instance, () => {
|
|
166
167
|
this.root.updateBlockedByResize = true;
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
cancelDelay && cancelDelay();
|
|
169
|
+
cancelDelay = delay(resizeUnblockUpdate, 250);
|
|
169
170
|
if (globalProjectionState.hasAnimatedSinceResize) {
|
|
170
171
|
globalProjectionState.hasAnimatedSinceResize = false;
|
|
171
172
|
this.nodes.forEach(finishAnimation);
|
|
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
22
22
|
* and warn against mismatches.
|
|
23
23
|
*/
|
|
24
24
|
if (process.env.NODE_ENV === "development") {
|
|
25
|
-
warnOnce(nextValue.version === "7.
|
|
25
|
+
warnOnce(nextValue.version === "7.6.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.0 may not work as expected.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else if (isMotionValue(prevValue)) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import sync, { cancelSync } from 'framesync';
|
|
2
|
+
|
|
3
|
+
function delay(callback, timeout) {
|
|
4
|
+
const start = performance.now();
|
|
5
|
+
const checkElapsed = ({ timestamp }) => {
|
|
6
|
+
const elapsed = timestamp - start;
|
|
7
|
+
if (elapsed >= timeout) {
|
|
8
|
+
cancelSync.read(checkElapsed);
|
|
9
|
+
callback(elapsed - timeout);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
sync.read(checkElapsed, true);
|
|
13
|
+
return () => cancelSync.read(checkElapsed);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { delay };
|
package/dist/es/value/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ class MotionValue {
|
|
|
24
24
|
* This will be replaced by the build step with the latest version number.
|
|
25
25
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
26
26
|
*/
|
|
27
|
-
this.version = "7.
|
|
27
|
+
this.version = "7.6.0";
|
|
28
28
|
/**
|
|
29
29
|
* Duration, in milliseconds, since last updating frame.
|
|
30
30
|
*
|
|
@@ -3126,12 +3126,25 @@
|
|
|
3126
3126
|
current: false,
|
|
3127
3127
|
};
|
|
3128
3128
|
|
|
3129
|
+
function delay(callback, timeout) {
|
|
3130
|
+
const start = performance.now();
|
|
3131
|
+
const checkElapsed = ({ timestamp }) => {
|
|
3132
|
+
const elapsed = timestamp - start;
|
|
3133
|
+
if (elapsed >= timeout) {
|
|
3134
|
+
cancelSync.read(checkElapsed);
|
|
3135
|
+
callback(elapsed - timeout);
|
|
3136
|
+
}
|
|
3137
|
+
};
|
|
3138
|
+
sync.read(checkElapsed, true);
|
|
3139
|
+
return () => cancelSync.read(checkElapsed);
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3129
3142
|
/**
|
|
3130
3143
|
* Decide whether a transition is defined on a given Transition.
|
|
3131
3144
|
* This filters out orchestration options and returns true
|
|
3132
3145
|
* if any options are left.
|
|
3133
3146
|
*/
|
|
3134
|
-
function isTransitionDefined({ when, delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, ...transition }) {
|
|
3147
|
+
function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, ...transition }) {
|
|
3135
3148
|
return !!Object.keys(transition).length;
|
|
3136
3149
|
}
|
|
3137
3150
|
let legacyRepeatWarning = false;
|
|
@@ -3306,19 +3319,19 @@
|
|
|
3306
3319
|
transition = { type: false };
|
|
3307
3320
|
}
|
|
3308
3321
|
return value.start((onComplete) => {
|
|
3309
|
-
let delayTimer;
|
|
3310
3322
|
let controls;
|
|
3311
3323
|
const animation = getAnimation(key, value, target, transition, onComplete);
|
|
3312
|
-
const
|
|
3324
|
+
const delayBy = getDelayFromTransition(transition, key);
|
|
3313
3325
|
const start = () => (controls = animation());
|
|
3314
|
-
|
|
3315
|
-
|
|
3326
|
+
let cancelDelay;
|
|
3327
|
+
if (delayBy) {
|
|
3328
|
+
cancelDelay = delay(start, secondsToMilliseconds(delayBy));
|
|
3316
3329
|
}
|
|
3317
3330
|
else {
|
|
3318
3331
|
start();
|
|
3319
3332
|
}
|
|
3320
3333
|
return () => {
|
|
3321
|
-
|
|
3334
|
+
cancelDelay && cancelDelay();
|
|
3322
3335
|
controls && controls.stop();
|
|
3323
3336
|
};
|
|
3324
3337
|
});
|
|
@@ -3413,7 +3426,7 @@
|
|
|
3413
3426
|
* This will be replaced by the build step with the latest version number.
|
|
3414
3427
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
3415
3428
|
*/
|
|
3416
|
-
this.version = "7.
|
|
3429
|
+
this.version = "7.6.0";
|
|
3417
3430
|
/**
|
|
3418
3431
|
* Duration, in milliseconds, since last updating frame.
|
|
3419
3432
|
*
|
|
@@ -5391,7 +5404,7 @@
|
|
|
5391
5404
|
* and warn against mismatches.
|
|
5392
5405
|
*/
|
|
5393
5406
|
{
|
|
5394
|
-
warnOnce(nextValue.version === "7.
|
|
5407
|
+
warnOnce(nextValue.version === "7.6.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 7.6.0 may not work as expected.`);
|
|
5395
5408
|
}
|
|
5396
5409
|
}
|
|
5397
5410
|
else if (isMotionValue(prevValue)) {
|
|
@@ -7096,12 +7109,12 @@
|
|
|
7096
7109
|
this.isLayoutDirty = true;
|
|
7097
7110
|
}
|
|
7098
7111
|
if (attachResizeListener) {
|
|
7099
|
-
let
|
|
7112
|
+
let cancelDelay;
|
|
7100
7113
|
const resizeUnblockUpdate = () => (this.root.updateBlockedByResize = false);
|
|
7101
7114
|
attachResizeListener(instance, () => {
|
|
7102
7115
|
this.root.updateBlockedByResize = true;
|
|
7103
|
-
|
|
7104
|
-
|
|
7116
|
+
cancelDelay && cancelDelay();
|
|
7117
|
+
cancelDelay = delay(resizeUnblockUpdate, 250);
|
|
7105
7118
|
if (globalProjectionState.hasAnimatedSinceResize) {
|
|
7106
7119
|
globalProjectionState.hasAnimatedSinceResize = false;
|
|
7107
7120
|
this.nodes.forEach(finishAnimation);
|
|
@@ -10183,6 +10196,7 @@
|
|
|
10183
10196
|
exports.createBox = createBox;
|
|
10184
10197
|
exports.createDomMotionComponent = createDomMotionComponent;
|
|
10185
10198
|
exports.createMotionComponent = createMotionComponent;
|
|
10199
|
+
exports.delay = delay;
|
|
10186
10200
|
exports.domAnimation = domAnimation;
|
|
10187
10201
|
exports.domMax = domMax;
|
|
10188
10202
|
exports.filterProps = filterProps;
|