framer-motion 10.2.3 → 10.2.5
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 +39 -25
- package/dist/cjs/{wrap-27fda06a.js → wrap-0d5542ae.js} +473 -454
- package/dist/dom-entry.d.ts +485 -37
- package/dist/es/animation/GroupPlaybackControls.mjs +25 -0
- package/dist/es/animation/animate.mjs +2 -3
- package/dist/es/animation/create-instant-animation.mjs +13 -3
- package/dist/es/animation/generators/inertia.mjs +87 -0
- package/dist/es/animation/{legacy-popmotion → generators}/keyframes.mjs +8 -15
- package/dist/es/animation/{legacy-popmotion/find-spring.mjs → generators/spring/find.mjs} +6 -5
- package/dist/es/animation/generators/spring/index.mjs +129 -0
- package/dist/es/animation/generators/utils/velocity.mjs +9 -0
- package/dist/es/animation/index.mjs +2 -10
- package/dist/es/animation/js/driver-frameloop.mjs +12 -0
- package/dist/es/animation/js/index.mjs +206 -0
- package/dist/es/animation/optimized-appear/handoff.mjs +3 -1
- package/dist/es/animation/waapi/create-accelerated-animation.mjs +16 -10
- package/dist/es/frameloop/index.mjs +3 -4
- package/dist/es/gestures/pan/PanSession.mjs +2 -2
- package/dist/es/index.mjs +2 -3
- package/dist/es/projection/node/create-projection-node.mjs +22 -5
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/utils/time-conversion.mjs +2 -1
- package/dist/es/value/index.mjs +3 -3
- package/dist/es/value/use-spring.mjs +1 -1
- package/dist/es/value/use-velocity.mjs +4 -6
- package/dist/framer-motion.dev.js +4004 -3971
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +177 -219
- package/dist/projection.dev.js +5866 -5830
- package/dist/three-entry.d.ts +64 -64
- package/package.json +7 -11
- package/dist/es/animation/legacy-popmotion/decay.mjs +0 -34
- package/dist/es/animation/legacy-popmotion/index.mjs +0 -163
- package/dist/es/animation/legacy-popmotion/inertia.mjs +0 -90
- package/dist/es/animation/legacy-popmotion/spring.mjs +0 -143
- package/dist/es/frameloop/on-next-frame.mjs +0 -12
package/dist/cjs/dom-entry.js
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
|
-
var wrap = require('./wrap-
|
|
6
|
+
var wrap = require('./wrap-0d5542ae.js');
|
|
7
7
|
|
|
8
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
9
|
|
|
@@ -2392,7 +2392,7 @@ function getVelocity(history, timeDelta) {
|
|
|
2392
2392
|
if (!timestampedPoint) {
|
|
2393
2393
|
return { x: 0, y: 0 };
|
|
2394
2394
|
}
|
|
2395
|
-
const time = (lastPoint.timestamp - timestampedPoint.timestamp)
|
|
2395
|
+
const time = wrap.millisecondsToSeconds(lastPoint.timestamp - timestampedPoint.timestamp);
|
|
2396
2396
|
if (time === 0) {
|
|
2397
2397
|
return { x: 0, y: 0 };
|
|
2398
2398
|
}
|
|
@@ -4227,10 +4227,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
4227
4227
|
this.target = undefined;
|
|
4228
4228
|
this.isLayoutDirty = false;
|
|
4229
4229
|
}
|
|
4230
|
-
|
|
4231
|
-
* Frame calculations
|
|
4232
|
-
*/
|
|
4233
|
-
resolveTargetDelta() {
|
|
4230
|
+
resolveTargetDelta(forceRecalculation = false) {
|
|
4234
4231
|
var _a;
|
|
4235
4232
|
/**
|
|
4236
4233
|
* Once the dirty status of nodes has been spread through the tree, we also
|
|
@@ -4246,7 +4243,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
4246
4243
|
* We don't use transform for this step of processing so we don't
|
|
4247
4244
|
* need to check whether any nodes have changed transform.
|
|
4248
4245
|
*/
|
|
4249
|
-
const canSkip = !(
|
|
4246
|
+
const canSkip = !(forceRecalculation ||
|
|
4247
|
+
(isShared && this.isSharedProjectionDirty) ||
|
|
4250
4248
|
this.isProjectionDirty ||
|
|
4251
4249
|
((_a = this.parent) === null || _a === void 0 ? void 0 : _a.isProjectionDirty) ||
|
|
4252
4250
|
this.attemptToResolveRelativeTarget);
|
|
@@ -4258,6 +4256,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
4258
4256
|
*/
|
|
4259
4257
|
if (!this.layout || !(layout || layoutId))
|
|
4260
4258
|
return;
|
|
4259
|
+
this.resolvedRelativeTargetAt = wrap.frameData.timestamp;
|
|
4261
4260
|
/**
|
|
4262
4261
|
* If we don't have a targetDelta but do have a layout, we can attempt to resolve
|
|
4263
4262
|
* a relativeParent. This will allow a component to perform scale correction
|
|
@@ -4298,6 +4297,16 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
4298
4297
|
this.relativeTargetOrigin &&
|
|
4299
4298
|
this.relativeParent &&
|
|
4300
4299
|
this.relativeParent.target) {
|
|
4300
|
+
/**
|
|
4301
|
+
* If the parent target isn't up-to-date, force it to update.
|
|
4302
|
+
* This is an unfortunate de-optimisation as it means any updating relative
|
|
4303
|
+
* projection will cause all the relative parents to recalculate back
|
|
4304
|
+
* up the tree.
|
|
4305
|
+
*/
|
|
4306
|
+
if (this.relativeParent.resolvedRelativeTargetAt !==
|
|
4307
|
+
wrap.frameData.timestamp) {
|
|
4308
|
+
this.relativeParent.resolveTargetDelta(true);
|
|
4309
|
+
}
|
|
4301
4310
|
calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target);
|
|
4302
4311
|
/**
|
|
4303
4312
|
* If we've only got a targetDelta, resolve it into a target
|
|
@@ -4384,6 +4393,13 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
4384
4393
|
(this.isSharedProjectionDirty || this.isTransformDirty)) {
|
|
4385
4394
|
canSkip = false;
|
|
4386
4395
|
}
|
|
4396
|
+
/**
|
|
4397
|
+
* If we have resolved the target this frame we must recalculate the
|
|
4398
|
+
* projection to ensure it visually represents the internal calculations.
|
|
4399
|
+
*/
|
|
4400
|
+
if (this.resolvedRelativeTargetAt === wrap.frameData.timestamp) {
|
|
4401
|
+
canSkip = false;
|
|
4402
|
+
}
|
|
4387
4403
|
if (canSkip)
|
|
4388
4404
|
return;
|
|
4389
4405
|
const { layout, layoutId } = this.options;
|
|
@@ -5516,7 +5532,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
5516
5532
|
* and warn against mismatches.
|
|
5517
5533
|
*/
|
|
5518
5534
|
if (process.env.NODE_ENV === "development") {
|
|
5519
|
-
wrap.warnOnce(nextValue.version === "10.2.
|
|
5535
|
+
wrap.warnOnce(nextValue.version === "10.2.5", `Attempting to mix Framer Motion versions ${nextValue.version} with 10.2.5 may not work as expected.`);
|
|
5520
5536
|
}
|
|
5521
5537
|
}
|
|
5522
5538
|
else if (wrap.isMotionValue(prevValue)) {
|
|
@@ -7114,6 +7130,16 @@ function useSpring(source, config = {}) {
|
|
|
7114
7130
|
return value;
|
|
7115
7131
|
}
|
|
7116
7132
|
|
|
7133
|
+
function useMotionValueEvent(value, event, callback) {
|
|
7134
|
+
/**
|
|
7135
|
+
* useInsertionEffect will create subscriptions before any other
|
|
7136
|
+
* effects will run. Effects run upwards through the tree so it
|
|
7137
|
+
* can be that binding a useLayoutEffect higher up the tree can
|
|
7138
|
+
* miss changes from lower down the tree.
|
|
7139
|
+
*/
|
|
7140
|
+
React.useInsertionEffect(() => value.on(event, callback), [value, event, callback]);
|
|
7141
|
+
}
|
|
7142
|
+
|
|
7117
7143
|
/**
|
|
7118
7144
|
* Creates a `MotionValue` that updates when the velocity of the provided `MotionValue` changes.
|
|
7119
7145
|
*
|
|
@@ -7127,11 +7153,9 @@ function useSpring(source, config = {}) {
|
|
|
7127
7153
|
*/
|
|
7128
7154
|
function useVelocity(value) {
|
|
7129
7155
|
const velocity = useMotionValue(value.getVelocity());
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
});
|
|
7134
|
-
}, [value]);
|
|
7156
|
+
useMotionValueEvent(value, "velocityChange", (newVelocity) => {
|
|
7157
|
+
velocity.set(newVelocity);
|
|
7158
|
+
});
|
|
7135
7159
|
return velocity;
|
|
7136
7160
|
}
|
|
7137
7161
|
|
|
@@ -7250,16 +7274,6 @@ function useWillChange() {
|
|
|
7250
7274
|
return useConstant(() => new WillChangeMotionValue("auto"));
|
|
7251
7275
|
}
|
|
7252
7276
|
|
|
7253
|
-
function useMotionValueEvent(value, event, callback) {
|
|
7254
|
-
/**
|
|
7255
|
-
* useInsertionEffect will create subscriptions before any other
|
|
7256
|
-
* effects will run. Effects run upwards through the tree so it
|
|
7257
|
-
* can be that binding a useLayoutEffect higher up the tree can
|
|
7258
|
-
* miss changes from lower down the tree.
|
|
7259
|
-
*/
|
|
7260
|
-
React.useInsertionEffect(() => value.on(event, callback), [value, event, callback]);
|
|
7261
|
-
}
|
|
7262
|
-
|
|
7263
7277
|
/**
|
|
7264
7278
|
* A hook that returns `true` if we should be using reduced motion based on the current device's Reduced Motion setting.
|
|
7265
7279
|
*
|
|
@@ -7681,7 +7695,8 @@ sync) {
|
|
|
7681
7695
|
*/
|
|
7682
7696
|
sync.update(() => {
|
|
7683
7697
|
if (value.animation) {
|
|
7684
|
-
value.animation.currentTime =
|
|
7698
|
+
value.animation.currentTime =
|
|
7699
|
+
performance.now() - wrap.millisecondsToSeconds(sampledTime);
|
|
7685
7700
|
}
|
|
7686
7701
|
});
|
|
7687
7702
|
/**
|
|
@@ -7884,7 +7899,6 @@ exports.easeInOut = wrap.easeInOut;
|
|
|
7884
7899
|
exports.easeOut = wrap.easeOut;
|
|
7885
7900
|
exports.frameData = wrap.frameData;
|
|
7886
7901
|
exports.inView = wrap.inView;
|
|
7887
|
-
exports.inertia = wrap.inertia;
|
|
7888
7902
|
exports.interpolate = wrap.interpolate;
|
|
7889
7903
|
Object.defineProperty(exports, 'invariant', {
|
|
7890
7904
|
enumerable: true,
|