framer-motion 11.2.10 → 11.3.0-alpha.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-Dvf42Jkp.js → dom-entry-D8KKo_ZB.js} +65 -117
- package/dist/cjs/dom-entry.js +1 -1
- package/dist/cjs/index.js +140 -40
- package/dist/dom.js +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs +1 -0
- package/dist/es/animation/optimized-appear/handoff.mjs +2 -0
- package/dist/es/animation/optimized-appear/start.mjs +1 -0
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +5 -3
- package/dist/es/gestures/drag/index.mjs +2 -0
- package/dist/es/motion/features/animation/index.mjs +6 -3
- package/dist/es/motion/features/layout/MeasureLayout.mjs +1 -0
- package/dist/es/motion/index.mjs +33 -13
- package/dist/es/motion/utils/use-motion-ref.mjs +6 -3
- package/dist/es/motion/utils/use-visual-element.mjs +55 -4
- package/dist/es/projection/node/create-projection-node.mjs +11 -4
- package/dist/es/projection/shared/stack.mjs +1 -0
- package/dist/es/projection-entry.mjs +11 -0
- package/dist/es/render/VisualElement.mjs +46 -94
- package/dist/es/render/utils/animation-state.mjs +5 -1
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/utils/use-instant-transition.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/es/value/types/color/rgba.mjs +1 -1
- package/dist/framer-motion.dev.js +198 -149
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +240 -384
- package/dist/three-entry.d.ts +62 -75
- package/package.json +12 -26
- package/dist/projection.dev.js +0 -6665
|
@@ -179,12 +179,6 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
|
|
|
179
179
|
return { schedule, cancel, state, steps };
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
function isRefObject(ref) {
|
|
183
|
-
return (ref &&
|
|
184
|
-
typeof ref === "object" &&
|
|
185
|
-
Object.prototype.hasOwnProperty.call(ref, "current"));
|
|
186
|
-
}
|
|
187
|
-
|
|
188
182
|
/**
|
|
189
183
|
* Decides if the supplied variable is variant label
|
|
190
184
|
*/
|
|
@@ -244,6 +238,23 @@ for (const key in featureProps) {
|
|
|
244
238
|
};
|
|
245
239
|
}
|
|
246
240
|
|
|
241
|
+
const noop = (any) => any;
|
|
242
|
+
|
|
243
|
+
exports.warning = noop;
|
|
244
|
+
exports.invariant = noop;
|
|
245
|
+
if (process.env.NODE_ENV !== "production") {
|
|
246
|
+
exports.warning = (check, message) => {
|
|
247
|
+
if (!check && typeof console !== "undefined") {
|
|
248
|
+
console.warn(message);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
exports.invariant = (check, message) => {
|
|
252
|
+
if (!check) {
|
|
253
|
+
throw new Error(message);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
247
258
|
const scaleCorrectors = {};
|
|
248
259
|
function addScaleCorrector(correctors) {
|
|
249
260
|
Object.assign(scaleCorrectors, correctors);
|
|
@@ -755,8 +766,6 @@ const resolveFinalValueInKeyframes = (v) => {
|
|
|
755
766
|
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
|
756
767
|
};
|
|
757
768
|
|
|
758
|
-
const noop = (any) => any;
|
|
759
|
-
|
|
760
769
|
const { schedule: frame, cancel: cancelFrame, state: frameData, steps, } = createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : noop, true);
|
|
761
770
|
|
|
762
771
|
/**
|
|
@@ -893,21 +902,6 @@ function isNone(value) {
|
|
|
893
902
|
}
|
|
894
903
|
}
|
|
895
904
|
|
|
896
|
-
exports.warning = noop;
|
|
897
|
-
exports.invariant = noop;
|
|
898
|
-
if (process.env.NODE_ENV !== "production") {
|
|
899
|
-
exports.warning = (check, message) => {
|
|
900
|
-
if (!check && typeof console !== "undefined") {
|
|
901
|
-
console.warn(message);
|
|
902
|
-
}
|
|
903
|
-
};
|
|
904
|
-
exports.invariant = (check, message) => {
|
|
905
|
-
if (!check) {
|
|
906
|
-
throw new Error(message);
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
|
|
911
905
|
/**
|
|
912
906
|
* Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
|
|
913
907
|
*/
|
|
@@ -3553,7 +3547,7 @@ class MotionValue {
|
|
|
3553
3547
|
* This will be replaced by the build step with the latest version number.
|
|
3554
3548
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
3555
3549
|
*/
|
|
3556
|
-
this.version = "11.
|
|
3550
|
+
this.version = "11.3.0-alpha.0";
|
|
3557
3551
|
/**
|
|
3558
3552
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
3559
3553
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -3904,6 +3898,7 @@ function animateTarget(visualElement, targetAndTransition, { delay = 0, transiti
|
|
|
3904
3898
|
const appearId = getOptimisedAppearId(visualElement);
|
|
3905
3899
|
if (appearId) {
|
|
3906
3900
|
const elapsed = window.HandoffAppearAnimations(appearId, key, value, frame);
|
|
3901
|
+
console.log({ elapsed, isAnimating: value.isAnimating() });
|
|
3907
3902
|
if (elapsed !== null) {
|
|
3908
3903
|
valueTransition.elapsed = elapsed;
|
|
3909
3904
|
isHandoff = true;
|
|
@@ -4233,7 +4228,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
4233
4228
|
* and warn against mismatches.
|
|
4234
4229
|
*/
|
|
4235
4230
|
if (process.env.NODE_ENV === "development") {
|
|
4236
|
-
warnOnce(nextValue.version === "11.
|
|
4231
|
+
warnOnce(nextValue.version === "11.3.0-alpha.0", `Attempting to mix Framer Motion versions ${nextValue.version} with 11.3.0-alpha.0 may not work as expected.`);
|
|
4237
4232
|
}
|
|
4238
4233
|
}
|
|
4239
4234
|
else if (isMotionValue(prevValue)) {
|
|
@@ -4284,8 +4279,6 @@ const valueTypes = [...dimensionValueTypes, color, complex];
|
|
|
4284
4279
|
*/
|
|
4285
4280
|
const findValueType = (v) => valueTypes.find(testValueType(v));
|
|
4286
4281
|
|
|
4287
|
-
const featureNames = Object.keys(featureDefinitions);
|
|
4288
|
-
const numFeatures = featureNames.length;
|
|
4289
4282
|
const propEventHandlers = [
|
|
4290
4283
|
"AnimationStart",
|
|
4291
4284
|
"AnimationComplete",
|
|
@@ -4296,13 +4289,6 @@ const propEventHandlers = [
|
|
|
4296
4289
|
"LayoutAnimationComplete",
|
|
4297
4290
|
];
|
|
4298
4291
|
const numVariantProps = variantProps.length;
|
|
4299
|
-
function getClosestProjectingNode(visualElement) {
|
|
4300
|
-
if (!visualElement)
|
|
4301
|
-
return undefined;
|
|
4302
|
-
return visualElement.options.allowProjection !== false
|
|
4303
|
-
? visualElement.projection
|
|
4304
|
-
: getClosestProjectingNode(visualElement.parent);
|
|
4305
|
-
}
|
|
4306
4292
|
/**
|
|
4307
4293
|
* A VisualElement is an imperative abstraction around UI elements such as
|
|
4308
4294
|
* HTMLElement, SVGElement, Three.Object3D etc.
|
|
@@ -4380,6 +4366,26 @@ class VisualElement {
|
|
|
4380
4366
|
* VisualElement.on(), but only one of those can be defined via the onUpdate prop.
|
|
4381
4367
|
*/
|
|
4382
4368
|
this.propEventSubscriptions = {};
|
|
4369
|
+
this.unmount = () => {
|
|
4370
|
+
visualElementStore.delete(this.current);
|
|
4371
|
+
this.projection && this.projection.unmount();
|
|
4372
|
+
cancelFrame(this.notifyUpdate);
|
|
4373
|
+
cancelFrame(this.render);
|
|
4374
|
+
this.valueSubscriptions.forEach((remove) => remove());
|
|
4375
|
+
this.removeFromVariantTree && this.removeFromVariantTree();
|
|
4376
|
+
this.parent && this.parent.children.delete(this);
|
|
4377
|
+
for (const key in this.events) {
|
|
4378
|
+
this.events[key].clear();
|
|
4379
|
+
}
|
|
4380
|
+
for (const key in this.features) {
|
|
4381
|
+
const feature = this.features[key];
|
|
4382
|
+
if (feature) {
|
|
4383
|
+
feature.unmount();
|
|
4384
|
+
feature.isMounted = false;
|
|
4385
|
+
}
|
|
4386
|
+
}
|
|
4387
|
+
this.current = null;
|
|
4388
|
+
};
|
|
4383
4389
|
this.notifyUpdate = () => this.notify("Update", this.latestValues);
|
|
4384
4390
|
this.render = () => {
|
|
4385
4391
|
if (!this.current)
|
|
@@ -4453,23 +4459,6 @@ class VisualElement {
|
|
|
4453
4459
|
this.parent.children.add(this);
|
|
4454
4460
|
this.update(this.props, this.presenceContext);
|
|
4455
4461
|
}
|
|
4456
|
-
unmount() {
|
|
4457
|
-
var _a;
|
|
4458
|
-
visualElementStore.delete(this.current);
|
|
4459
|
-
this.projection && this.projection.unmount();
|
|
4460
|
-
cancelFrame(this.notifyUpdate);
|
|
4461
|
-
cancelFrame(this.render);
|
|
4462
|
-
this.valueSubscriptions.forEach((remove) => remove());
|
|
4463
|
-
this.removeFromVariantTree && this.removeFromVariantTree();
|
|
4464
|
-
this.parent && this.parent.children.delete(this);
|
|
4465
|
-
for (const key in this.events) {
|
|
4466
|
-
this.events[key].clear();
|
|
4467
|
-
}
|
|
4468
|
-
for (const key in this.features) {
|
|
4469
|
-
(_a = this.features[key]) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
4470
|
-
}
|
|
4471
|
-
this.current = null;
|
|
4472
|
-
}
|
|
4473
4462
|
bindToMotionValue(key, value) {
|
|
4474
4463
|
const valueIsTransform = transformProps.has(key);
|
|
4475
4464
|
const removeOnChange = value.on("change", (latestValue) => {
|
|
@@ -4498,73 +4487,33 @@ class VisualElement {
|
|
|
4498
4487
|
}
|
|
4499
4488
|
return this.sortInstanceNodePosition(this.current, other.current);
|
|
4500
4489
|
}
|
|
4501
|
-
loadFeatures({ children, ...renderedProps }, isStrict, preloadedFeatures, initialLayoutGroupConfig) {
|
|
4502
|
-
let ProjectionNodeConstructor;
|
|
4503
|
-
let MeasureLayout;
|
|
4504
|
-
/**
|
|
4505
|
-
* If we're in development mode, check to make sure we're not rendering a motion component
|
|
4506
|
-
* as a child of LazyMotion, as this will break the file-size benefits of using it.
|
|
4507
|
-
*/
|
|
4508
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
4509
|
-
preloadedFeatures &&
|
|
4510
|
-
isStrict) {
|
|
4511
|
-
const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
|
|
4512
|
-
renderedProps.ignoreStrict
|
|
4513
|
-
? exports.warning(false, strictMessage)
|
|
4514
|
-
: exports.invariant(false, strictMessage);
|
|
4515
|
-
}
|
|
4516
|
-
for (let i = 0; i < numFeatures; i++) {
|
|
4517
|
-
const name = featureNames[i];
|
|
4518
|
-
const { isEnabled, Feature: FeatureConstructor, ProjectionNode, MeasureLayout: MeasureLayoutComponent, } = featureDefinitions[name];
|
|
4519
|
-
if (ProjectionNode)
|
|
4520
|
-
ProjectionNodeConstructor = ProjectionNode;
|
|
4521
|
-
if (isEnabled(renderedProps)) {
|
|
4522
|
-
if (!this.features[name] && FeatureConstructor) {
|
|
4523
|
-
this.features[name] = new FeatureConstructor(this);
|
|
4524
|
-
}
|
|
4525
|
-
if (MeasureLayoutComponent) {
|
|
4526
|
-
MeasureLayout = MeasureLayoutComponent;
|
|
4527
|
-
}
|
|
4528
|
-
}
|
|
4529
|
-
}
|
|
4530
|
-
if ((this.type === "html" || this.type === "svg") &&
|
|
4531
|
-
!this.projection &&
|
|
4532
|
-
ProjectionNodeConstructor) {
|
|
4533
|
-
const { layoutId, layout, drag, dragConstraints, layoutScroll, layoutRoot, } = renderedProps;
|
|
4534
|
-
this.projection = new ProjectionNodeConstructor(this.latestValues, renderedProps["data-framer-portal-id"]
|
|
4535
|
-
? undefined
|
|
4536
|
-
: getClosestProjectingNode(this.parent));
|
|
4537
|
-
this.projection.setOptions({
|
|
4538
|
-
layoutId,
|
|
4539
|
-
layout,
|
|
4540
|
-
alwaysMeasureLayout: Boolean(drag) ||
|
|
4541
|
-
(dragConstraints && isRefObject(dragConstraints)),
|
|
4542
|
-
visualElement: this,
|
|
4543
|
-
scheduleRender: () => this.scheduleRender(),
|
|
4544
|
-
/**
|
|
4545
|
-
* TODO: Update options in an effect. This could be tricky as it'll be too late
|
|
4546
|
-
* to update by the time layout animations run.
|
|
4547
|
-
* We also need to fix this safeToRemove by linking it up to the one returned by usePresence,
|
|
4548
|
-
* ensuring it gets called if there's no potential layout animations.
|
|
4549
|
-
*
|
|
4550
|
-
*/
|
|
4551
|
-
animationType: typeof layout === "string" ? layout : "both",
|
|
4552
|
-
initialPromotionConfig: initialLayoutGroupConfig,
|
|
4553
|
-
layoutScroll,
|
|
4554
|
-
layoutRoot,
|
|
4555
|
-
});
|
|
4556
|
-
}
|
|
4557
|
-
return MeasureLayout;
|
|
4558
|
-
}
|
|
4559
4490
|
updateFeatures() {
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4491
|
+
let key = "animation";
|
|
4492
|
+
for (key in featureDefinitions) {
|
|
4493
|
+
const featureDefinition = featureDefinitions[key];
|
|
4494
|
+
if (!featureDefinition)
|
|
4495
|
+
continue;
|
|
4496
|
+
const { isEnabled, Feature: FeatureConstructor } = featureDefinition;
|
|
4497
|
+
/**
|
|
4498
|
+
* If this feature is enabled but not active, make a new instance.
|
|
4499
|
+
*/
|
|
4500
|
+
if (!this.features[key] &&
|
|
4501
|
+
FeatureConstructor &&
|
|
4502
|
+
isEnabled(this.props)) {
|
|
4503
|
+
this.features[key] = new FeatureConstructor(this);
|
|
4564
4504
|
}
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4505
|
+
/**
|
|
4506
|
+
* If we have a feature, mount or update it.
|
|
4507
|
+
*/
|
|
4508
|
+
if (this.features[key]) {
|
|
4509
|
+
const feature = this.features[key];
|
|
4510
|
+
if (feature.isMounted) {
|
|
4511
|
+
feature.update();
|
|
4512
|
+
}
|
|
4513
|
+
else {
|
|
4514
|
+
feature.mount();
|
|
4515
|
+
feature.isMounted = true;
|
|
4516
|
+
}
|
|
4568
4517
|
}
|
|
4569
4518
|
}
|
|
4570
4519
|
}
|
|
@@ -5964,7 +5913,6 @@ exports.isCustomValue = isCustomValue;
|
|
|
5964
5913
|
exports.isForcedMotionValue = isForcedMotionValue;
|
|
5965
5914
|
exports.isKeyframesTarget = isKeyframesTarget;
|
|
5966
5915
|
exports.isMotionValue = isMotionValue;
|
|
5967
|
-
exports.isRefObject = isRefObject;
|
|
5968
5916
|
exports.isSVGElement = isSVGElement;
|
|
5969
5917
|
exports.isSVGTag = isSVGTag;
|
|
5970
5918
|
exports.isVariantLabel = isVariantLabel;
|