framer-motion 12.9.2 → 12.9.4
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/client.js +1 -1
- package/dist/cjs/{create-CFQWONF8.js → create-C0aMAGDw.js} +2 -7
- package/dist/cjs/dom.js +140 -146
- package/dist/cjs/index.js +1 -1
- package/dist/dom.js +1 -1
- package/dist/es/animation/utils/create-visual-element.mjs +2 -2
- package/dist/es/projection/node/create-projection-node.mjs +1 -0
- package/dist/es/render/VisualElement.mjs +1 -0
- package/dist/es/render/utils/motion-values.mjs +0 -8
- package/dist/framer-motion.dev.js +3 -8
- package/dist/framer-motion.js +1 -1
- package/dist/size-rollup-animate.js +1 -1
- 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/package.json +4 -4
package/dist/cjs/client.js
CHANGED
|
@@ -1229,6 +1229,7 @@ function createProjectionNode$1({ attachResizeListener, defaultParent, measureSc
|
|
|
1229
1229
|
stack && stack.remove(this);
|
|
1230
1230
|
this.parent && this.parent.children.delete(this);
|
|
1231
1231
|
this.instance = undefined;
|
|
1232
|
+
this.eventHandlers.clear();
|
|
1232
1233
|
motionDom.cancelFrame(this.updateProjection);
|
|
1233
1234
|
}
|
|
1234
1235
|
// only on the root
|
|
@@ -2715,13 +2716,6 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
2715
2716
|
* to our visual element's motion value map.
|
|
2716
2717
|
*/
|
|
2717
2718
|
element.addValue(key, nextValue);
|
|
2718
|
-
/**
|
|
2719
|
-
* Check the version of the incoming motion value with this version
|
|
2720
|
-
* and warn against mismatches.
|
|
2721
|
-
*/
|
|
2722
|
-
if (process.env.NODE_ENV === "development") {
|
|
2723
|
-
motionUtils.warnOnce(nextValue.version === "12.9.2", `Attempting to mix Motion versions ${nextValue.version} with 12.9.2 may not work as expected.`);
|
|
2724
|
-
}
|
|
2725
2719
|
}
|
|
2726
2720
|
else if (isMotionValue(prevValue)) {
|
|
2727
2721
|
/**
|
|
@@ -2952,6 +2946,7 @@ class VisualElement {
|
|
|
2952
2946
|
}
|
|
2953
2947
|
unmount() {
|
|
2954
2948
|
this.projection && this.projection.unmount();
|
|
2949
|
+
this.projection = undefined;
|
|
2955
2950
|
motionDom.cancelFrame(this.notifyUpdate);
|
|
2956
2951
|
motionDom.cancelFrame(this.render);
|
|
2957
2952
|
this.valueSubscriptions.forEach((remove) => remove());
|
package/dist/cjs/dom.js
CHANGED
|
@@ -669,11 +669,38 @@ function isSVGElement(element) {
|
|
|
669
669
|
return element instanceof SVGElement && element.tagName !== "svg";
|
|
670
670
|
}
|
|
671
671
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
672
|
+
/**
|
|
673
|
+
* Bounding boxes tend to be defined as top, left, right, bottom. For various operations
|
|
674
|
+
* it's easier to consider each axis individually. This function returns a bounding box
|
|
675
|
+
* as a map of single-axis min/max values.
|
|
676
|
+
*/
|
|
677
|
+
function convertBoundingBoxToBox({ top, left, right, bottom, }) {
|
|
678
|
+
return {
|
|
679
|
+
x: { min: left, max: right },
|
|
680
|
+
y: { min: top, max: bottom },
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Applies a TransformPoint function to a bounding box. TransformPoint is usually a function
|
|
685
|
+
* provided by Framer to allow measured points to be corrected for device scaling. This is used
|
|
686
|
+
* when measuring DOM elements and DOM event points.
|
|
687
|
+
*/
|
|
688
|
+
function transformBoxPoints(point, transformPoint) {
|
|
689
|
+
if (!transformPoint)
|
|
690
|
+
return point;
|
|
691
|
+
const topLeft = transformPoint({ x: point.left, y: point.top });
|
|
692
|
+
const bottomRight = transformPoint({ x: point.right, y: point.bottom });
|
|
693
|
+
return {
|
|
694
|
+
top: topLeft.y,
|
|
695
|
+
left: topLeft.x,
|
|
696
|
+
bottom: bottomRight.y,
|
|
697
|
+
right: bottomRight.x,
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
function measureViewportBox(instance, transformPoint) {
|
|
702
|
+
return convertBoundingBoxToBox(transformBoxPoints(instance.getBoundingClientRect(), transformPoint));
|
|
703
|
+
}
|
|
677
704
|
|
|
678
705
|
const featureProps = {
|
|
679
706
|
animation: [
|
|
@@ -702,6 +729,12 @@ for (const key in featureProps) {
|
|
|
702
729
|
};
|
|
703
730
|
}
|
|
704
731
|
|
|
732
|
+
const createAxis = () => ({ min: 0, max: 0 });
|
|
733
|
+
const createBox = () => ({
|
|
734
|
+
x: createAxis(),
|
|
735
|
+
y: createAxis(),
|
|
736
|
+
});
|
|
737
|
+
|
|
705
738
|
const isBrowser = typeof window !== "undefined";
|
|
706
739
|
|
|
707
740
|
// Does this device prefer reduced motion? Returns `null` server-side.
|
|
@@ -765,13 +798,6 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
765
798
|
* to our visual element's motion value map.
|
|
766
799
|
*/
|
|
767
800
|
element.addValue(key, nextValue);
|
|
768
|
-
/**
|
|
769
|
-
* Check the version of the incoming motion value with this version
|
|
770
|
-
* and warn against mismatches.
|
|
771
|
-
*/
|
|
772
|
-
if (process.env.NODE_ENV === "development") {
|
|
773
|
-
motionUtils.warnOnce(nextValue.version === "12.9.2", `Attempting to mix Motion versions ${nextValue.version} with 12.9.2 may not work as expected.`);
|
|
774
|
-
}
|
|
775
801
|
}
|
|
776
802
|
else if (isMotionValue(prevValue)) {
|
|
777
803
|
/**
|
|
@@ -967,6 +993,7 @@ class VisualElement {
|
|
|
967
993
|
}
|
|
968
994
|
unmount() {
|
|
969
995
|
this.projection && this.projection.unmount();
|
|
996
|
+
this.projection = undefined;
|
|
970
997
|
motionDom.cancelFrame(this.notifyUpdate);
|
|
971
998
|
motionDom.cancelFrame(this.render);
|
|
972
999
|
this.valueSubscriptions.forEach((remove) => remove());
|
|
@@ -1417,6 +1444,107 @@ function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
|
1417
1444
|
}
|
|
1418
1445
|
}
|
|
1419
1446
|
|
|
1447
|
+
function renderHTML(element, { style, vars }, styleProp, projection) {
|
|
1448
|
+
Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
|
|
1449
|
+
// Loop over any CSS variables and assign those.
|
|
1450
|
+
for (const key in vars) {
|
|
1451
|
+
element.style.setProperty(key, vars[key]);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
const scaleCorrectors = {};
|
|
1456
|
+
|
|
1457
|
+
function isForcedMotionValue(key, { layout, layoutId }) {
|
|
1458
|
+
return (motionDom.transformProps.has(key) ||
|
|
1459
|
+
key.startsWith("origin") ||
|
|
1460
|
+
((layout || layoutId !== undefined) &&
|
|
1461
|
+
(!!scaleCorrectors[key] || key === "opacity")));
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
|
|
1465
|
+
const { style } = props;
|
|
1466
|
+
const newValues = {};
|
|
1467
|
+
for (const key in style) {
|
|
1468
|
+
if (isMotionValue(style[key]) ||
|
|
1469
|
+
(prevProps.style &&
|
|
1470
|
+
isMotionValue(prevProps.style[key])) ||
|
|
1471
|
+
isForcedMotionValue(key, props) ||
|
|
1472
|
+
visualElement?.getValue(key)?.liveStyle !== undefined) {
|
|
1473
|
+
newValues[key] = style[key];
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
return newValues;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
function getComputedStyle$1(element) {
|
|
1480
|
+
return window.getComputedStyle(element);
|
|
1481
|
+
}
|
|
1482
|
+
class HTMLVisualElement extends DOMVisualElement {
|
|
1483
|
+
constructor() {
|
|
1484
|
+
super(...arguments);
|
|
1485
|
+
this.type = "html";
|
|
1486
|
+
this.renderInstance = renderHTML;
|
|
1487
|
+
}
|
|
1488
|
+
readValueFromInstance(instance, key) {
|
|
1489
|
+
if (motionDom.transformProps.has(key)) {
|
|
1490
|
+
return motionDom.readTransformValue(instance, key);
|
|
1491
|
+
}
|
|
1492
|
+
else {
|
|
1493
|
+
const computedStyle = getComputedStyle$1(instance);
|
|
1494
|
+
const value = (motionDom.isCSSVariableName(key)
|
|
1495
|
+
? computedStyle.getPropertyValue(key)
|
|
1496
|
+
: computedStyle[key]) || 0;
|
|
1497
|
+
return typeof value === "string" ? value.trim() : value;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
measureInstanceViewportBox(instance, { transformPagePoint }) {
|
|
1501
|
+
return measureViewportBox(instance, transformPagePoint);
|
|
1502
|
+
}
|
|
1503
|
+
build(renderState, latestValues, props) {
|
|
1504
|
+
buildHTMLStyles(renderState, latestValues, props.transformTemplate);
|
|
1505
|
+
}
|
|
1506
|
+
scrapeMotionValuesFromProps(props, prevProps, visualElement) {
|
|
1507
|
+
return scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
function isObjectKey(key, object) {
|
|
1512
|
+
return key in object;
|
|
1513
|
+
}
|
|
1514
|
+
class ObjectVisualElement extends VisualElement {
|
|
1515
|
+
constructor() {
|
|
1516
|
+
super(...arguments);
|
|
1517
|
+
this.type = "object";
|
|
1518
|
+
}
|
|
1519
|
+
readValueFromInstance(instance, key) {
|
|
1520
|
+
if (isObjectKey(key, instance)) {
|
|
1521
|
+
const value = instance[key];
|
|
1522
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
1523
|
+
return value;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
return undefined;
|
|
1527
|
+
}
|
|
1528
|
+
getBaseTargetFromProps() {
|
|
1529
|
+
return undefined;
|
|
1530
|
+
}
|
|
1531
|
+
removeValueFromRenderState(key, renderState) {
|
|
1532
|
+
delete renderState.output[key];
|
|
1533
|
+
}
|
|
1534
|
+
measureInstanceViewportBox() {
|
|
1535
|
+
return createBox();
|
|
1536
|
+
}
|
|
1537
|
+
build(renderState, latestValues) {
|
|
1538
|
+
Object.assign(renderState.output, latestValues);
|
|
1539
|
+
}
|
|
1540
|
+
renderInstance(instance, { output }) {
|
|
1541
|
+
Object.assign(instance, output);
|
|
1542
|
+
}
|
|
1543
|
+
sortInstanceNodePosition() {
|
|
1544
|
+
return 0;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1420
1548
|
const dashKeys = {
|
|
1421
1549
|
offset: "stroke-dashoffset",
|
|
1422
1550
|
array: "stroke-dasharray",
|
|
@@ -1530,14 +1658,6 @@ const camelCaseAttributes = new Set([
|
|
|
1530
1658
|
|
|
1531
1659
|
const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
|
|
1532
1660
|
|
|
1533
|
-
function renderHTML(element, { style, vars }, styleProp, projection) {
|
|
1534
|
-
Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
|
|
1535
|
-
// Loop over any CSS variables and assign those.
|
|
1536
|
-
for (const key in vars) {
|
|
1537
|
-
element.style.setProperty(key, vars[key]);
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
1661
|
function renderSVG(element, renderState, _styleProp, projection) {
|
|
1542
1662
|
renderHTML(element, renderState, undefined, projection);
|
|
1543
1663
|
for (const key in renderState.attrs) {
|
|
@@ -1545,30 +1665,6 @@ function renderSVG(element, renderState, _styleProp, projection) {
|
|
|
1545
1665
|
}
|
|
1546
1666
|
}
|
|
1547
1667
|
|
|
1548
|
-
const scaleCorrectors = {};
|
|
1549
|
-
|
|
1550
|
-
function isForcedMotionValue(key, { layout, layoutId }) {
|
|
1551
|
-
return (motionDom.transformProps.has(key) ||
|
|
1552
|
-
key.startsWith("origin") ||
|
|
1553
|
-
((layout || layoutId !== undefined) &&
|
|
1554
|
-
(!!scaleCorrectors[key] || key === "opacity")));
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
|
|
1558
|
-
const { style } = props;
|
|
1559
|
-
const newValues = {};
|
|
1560
|
-
for (const key in style) {
|
|
1561
|
-
if (isMotionValue(style[key]) ||
|
|
1562
|
-
(prevProps.style &&
|
|
1563
|
-
isMotionValue(prevProps.style[key])) ||
|
|
1564
|
-
isForcedMotionValue(key, props) ||
|
|
1565
|
-
visualElement?.getValue(key)?.liveStyle !== undefined) {
|
|
1566
|
-
newValues[key] = style[key];
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
return newValues;
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
1668
|
function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
|
|
1573
1669
|
const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
|
|
1574
1670
|
for (const key in props) {
|
|
@@ -1616,108 +1712,6 @@ class SVGVisualElement extends DOMVisualElement {
|
|
|
1616
1712
|
}
|
|
1617
1713
|
}
|
|
1618
1714
|
|
|
1619
|
-
/**
|
|
1620
|
-
* Bounding boxes tend to be defined as top, left, right, bottom. For various operations
|
|
1621
|
-
* it's easier to consider each axis individually. This function returns a bounding box
|
|
1622
|
-
* as a map of single-axis min/max values.
|
|
1623
|
-
*/
|
|
1624
|
-
function convertBoundingBoxToBox({ top, left, right, bottom, }) {
|
|
1625
|
-
return {
|
|
1626
|
-
x: { min: left, max: right },
|
|
1627
|
-
y: { min: top, max: bottom },
|
|
1628
|
-
};
|
|
1629
|
-
}
|
|
1630
|
-
/**
|
|
1631
|
-
* Applies a TransformPoint function to a bounding box. TransformPoint is usually a function
|
|
1632
|
-
* provided by Framer to allow measured points to be corrected for device scaling. This is used
|
|
1633
|
-
* when measuring DOM elements and DOM event points.
|
|
1634
|
-
*/
|
|
1635
|
-
function transformBoxPoints(point, transformPoint) {
|
|
1636
|
-
if (!transformPoint)
|
|
1637
|
-
return point;
|
|
1638
|
-
const topLeft = transformPoint({ x: point.left, y: point.top });
|
|
1639
|
-
const bottomRight = transformPoint({ x: point.right, y: point.bottom });
|
|
1640
|
-
return {
|
|
1641
|
-
top: topLeft.y,
|
|
1642
|
-
left: topLeft.x,
|
|
1643
|
-
bottom: bottomRight.y,
|
|
1644
|
-
right: bottomRight.x,
|
|
1645
|
-
};
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
function measureViewportBox(instance, transformPoint) {
|
|
1649
|
-
return convertBoundingBoxToBox(transformBoxPoints(instance.getBoundingClientRect(), transformPoint));
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
function getComputedStyle$1(element) {
|
|
1653
|
-
return window.getComputedStyle(element);
|
|
1654
|
-
}
|
|
1655
|
-
class HTMLVisualElement extends DOMVisualElement {
|
|
1656
|
-
constructor() {
|
|
1657
|
-
super(...arguments);
|
|
1658
|
-
this.type = "html";
|
|
1659
|
-
this.renderInstance = renderHTML;
|
|
1660
|
-
}
|
|
1661
|
-
readValueFromInstance(instance, key) {
|
|
1662
|
-
if (motionDom.transformProps.has(key)) {
|
|
1663
|
-
return motionDom.readTransformValue(instance, key);
|
|
1664
|
-
}
|
|
1665
|
-
else {
|
|
1666
|
-
const computedStyle = getComputedStyle$1(instance);
|
|
1667
|
-
const value = (motionDom.isCSSVariableName(key)
|
|
1668
|
-
? computedStyle.getPropertyValue(key)
|
|
1669
|
-
: computedStyle[key]) || 0;
|
|
1670
|
-
return typeof value === "string" ? value.trim() : value;
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
measureInstanceViewportBox(instance, { transformPagePoint }) {
|
|
1674
|
-
return measureViewportBox(instance, transformPagePoint);
|
|
1675
|
-
}
|
|
1676
|
-
build(renderState, latestValues, props) {
|
|
1677
|
-
buildHTMLStyles(renderState, latestValues, props.transformTemplate);
|
|
1678
|
-
}
|
|
1679
|
-
scrapeMotionValuesFromProps(props, prevProps, visualElement) {
|
|
1680
|
-
return scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1684
|
-
function isObjectKey(key, object) {
|
|
1685
|
-
return key in object;
|
|
1686
|
-
}
|
|
1687
|
-
class ObjectVisualElement extends VisualElement {
|
|
1688
|
-
constructor() {
|
|
1689
|
-
super(...arguments);
|
|
1690
|
-
this.type = "object";
|
|
1691
|
-
}
|
|
1692
|
-
readValueFromInstance(instance, key) {
|
|
1693
|
-
if (isObjectKey(key, instance)) {
|
|
1694
|
-
const value = instance[key];
|
|
1695
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
1696
|
-
return value;
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
return undefined;
|
|
1700
|
-
}
|
|
1701
|
-
getBaseTargetFromProps() {
|
|
1702
|
-
return undefined;
|
|
1703
|
-
}
|
|
1704
|
-
removeValueFromRenderState(key, renderState) {
|
|
1705
|
-
delete renderState.output[key];
|
|
1706
|
-
}
|
|
1707
|
-
measureInstanceViewportBox() {
|
|
1708
|
-
return createBox();
|
|
1709
|
-
}
|
|
1710
|
-
build(renderState, latestValues) {
|
|
1711
|
-
Object.assign(renderState.output, latestValues);
|
|
1712
|
-
}
|
|
1713
|
-
renderInstance(instance, { output }) {
|
|
1714
|
-
Object.assign(instance, output);
|
|
1715
|
-
}
|
|
1716
|
-
sortInstanceNodePosition() {
|
|
1717
|
-
return 0;
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
1715
|
function createDOMVisualElement(element) {
|
|
1722
1716
|
const options = {
|
|
1723
1717
|
presenceContext: null,
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var create = require('./create-
|
|
7
|
+
var create = require('./create-C0aMAGDw.js');
|
|
8
8
|
var motionDom = require('motion-dom');
|
|
9
9
|
var motionUtils = require('motion-utils');
|
|
10
10
|
|