framer-motion 12.9.2 → 12.9.3

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var create = require('./create-CFQWONF8.js');
5
+ var create = require('./create-CIsbGW8k.js');
6
6
  require('motion-dom');
7
7
  require('motion-utils');
8
8
  require('react/jsx-runtime');
@@ -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
@@ -2720,7 +2721,7 @@ function updateMotionValuesFromProps(element, next, prev) {
2720
2721
  * and warn against mismatches.
2721
2722
  */
2722
2723
  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
+ motionUtils.warnOnce(nextValue.version === "12.9.3", `Attempting to mix Motion versions ${nextValue.version} with 12.9.3 may not work as expected.`);
2724
2725
  }
2725
2726
  }
2726
2727
  else if (isMotionValue(prevValue)) {
@@ -2952,6 +2953,7 @@ class VisualElement {
2952
2953
  }
2953
2954
  unmount() {
2954
2955
  this.projection && this.projection.unmount();
2956
+ this.projection = undefined;
2955
2957
  motionDom.cancelFrame(this.notifyUpdate);
2956
2958
  motionDom.cancelFrame(this.render);
2957
2959
  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
- const createAxis = () => ({ min: 0, max: 0 });
673
- const createBox = () => ({
674
- x: createAxis(),
675
- y: createAxis(),
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.
@@ -770,7 +803,7 @@ function updateMotionValuesFromProps(element, next, prev) {
770
803
  * and warn against mismatches.
771
804
  */
772
805
  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.`);
806
+ motionUtils.warnOnce(nextValue.version === "12.9.3", `Attempting to mix Motion versions ${nextValue.version} with 12.9.3 may not work as expected.`);
774
807
  }
775
808
  }
776
809
  else if (isMotionValue(prevValue)) {
@@ -967,6 +1000,7 @@ class VisualElement {
967
1000
  }
968
1001
  unmount() {
969
1002
  this.projection && this.projection.unmount();
1003
+ this.projection = undefined;
970
1004
  motionDom.cancelFrame(this.notifyUpdate);
971
1005
  motionDom.cancelFrame(this.render);
972
1006
  this.valueSubscriptions.forEach((remove) => remove());
@@ -1417,6 +1451,107 @@ function buildHTMLStyles(state, latestValues, transformTemplate) {
1417
1451
  }
1418
1452
  }
1419
1453
 
1454
+ function renderHTML(element, { style, vars }, styleProp, projection) {
1455
+ Object.assign(element.style, style, projection && projection.getProjectionStyles(styleProp));
1456
+ // Loop over any CSS variables and assign those.
1457
+ for (const key in vars) {
1458
+ element.style.setProperty(key, vars[key]);
1459
+ }
1460
+ }
1461
+
1462
+ const scaleCorrectors = {};
1463
+
1464
+ function isForcedMotionValue(key, { layout, layoutId }) {
1465
+ return (motionDom.transformProps.has(key) ||
1466
+ key.startsWith("origin") ||
1467
+ ((layout || layoutId !== undefined) &&
1468
+ (!!scaleCorrectors[key] || key === "opacity")));
1469
+ }
1470
+
1471
+ function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
1472
+ const { style } = props;
1473
+ const newValues = {};
1474
+ for (const key in style) {
1475
+ if (isMotionValue(style[key]) ||
1476
+ (prevProps.style &&
1477
+ isMotionValue(prevProps.style[key])) ||
1478
+ isForcedMotionValue(key, props) ||
1479
+ visualElement?.getValue(key)?.liveStyle !== undefined) {
1480
+ newValues[key] = style[key];
1481
+ }
1482
+ }
1483
+ return newValues;
1484
+ }
1485
+
1486
+ function getComputedStyle$1(element) {
1487
+ return window.getComputedStyle(element);
1488
+ }
1489
+ class HTMLVisualElement extends DOMVisualElement {
1490
+ constructor() {
1491
+ super(...arguments);
1492
+ this.type = "html";
1493
+ this.renderInstance = renderHTML;
1494
+ }
1495
+ readValueFromInstance(instance, key) {
1496
+ if (motionDom.transformProps.has(key)) {
1497
+ return motionDom.readTransformValue(instance, key);
1498
+ }
1499
+ else {
1500
+ const computedStyle = getComputedStyle$1(instance);
1501
+ const value = (motionDom.isCSSVariableName(key)
1502
+ ? computedStyle.getPropertyValue(key)
1503
+ : computedStyle[key]) || 0;
1504
+ return typeof value === "string" ? value.trim() : value;
1505
+ }
1506
+ }
1507
+ measureInstanceViewportBox(instance, { transformPagePoint }) {
1508
+ return measureViewportBox(instance, transformPagePoint);
1509
+ }
1510
+ build(renderState, latestValues, props) {
1511
+ buildHTMLStyles(renderState, latestValues, props.transformTemplate);
1512
+ }
1513
+ scrapeMotionValuesFromProps(props, prevProps, visualElement) {
1514
+ return scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
1515
+ }
1516
+ }
1517
+
1518
+ function isObjectKey(key, object) {
1519
+ return key in object;
1520
+ }
1521
+ class ObjectVisualElement extends VisualElement {
1522
+ constructor() {
1523
+ super(...arguments);
1524
+ this.type = "object";
1525
+ }
1526
+ readValueFromInstance(instance, key) {
1527
+ if (isObjectKey(key, instance)) {
1528
+ const value = instance[key];
1529
+ if (typeof value === "string" || typeof value === "number") {
1530
+ return value;
1531
+ }
1532
+ }
1533
+ return undefined;
1534
+ }
1535
+ getBaseTargetFromProps() {
1536
+ return undefined;
1537
+ }
1538
+ removeValueFromRenderState(key, renderState) {
1539
+ delete renderState.output[key];
1540
+ }
1541
+ measureInstanceViewportBox() {
1542
+ return createBox();
1543
+ }
1544
+ build(renderState, latestValues) {
1545
+ Object.assign(renderState.output, latestValues);
1546
+ }
1547
+ renderInstance(instance, { output }) {
1548
+ Object.assign(instance, output);
1549
+ }
1550
+ sortInstanceNodePosition() {
1551
+ return 0;
1552
+ }
1553
+ }
1554
+
1420
1555
  const dashKeys = {
1421
1556
  offset: "stroke-dashoffset",
1422
1557
  array: "stroke-dasharray",
@@ -1530,14 +1665,6 @@ const camelCaseAttributes = new Set([
1530
1665
 
1531
1666
  const isSVGTag = (tag) => typeof tag === "string" && tag.toLowerCase() === "svg";
1532
1667
 
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
1668
  function renderSVG(element, renderState, _styleProp, projection) {
1542
1669
  renderHTML(element, renderState, undefined, projection);
1543
1670
  for (const key in renderState.attrs) {
@@ -1545,30 +1672,6 @@ function renderSVG(element, renderState, _styleProp, projection) {
1545
1672
  }
1546
1673
  }
1547
1674
 
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
1675
  function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
1573
1676
  const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
1574
1677
  for (const key in props) {
@@ -1616,108 +1719,6 @@ class SVGVisualElement extends DOMVisualElement {
1616
1719
  }
1617
1720
  }
1618
1721
 
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
1722
  function createDOMVisualElement(element) {
1722
1723
  const options = {
1723
1724
  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-CFQWONF8.js');
7
+ var create = require('./create-CIsbGW8k.js');
8
8
  var motionDom = require('motion-dom');
9
9
  var motionUtils = require('motion-utils');
10
10