framer-motion 12.4.12 → 12.4.13
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-Da6xW2BP.js → create-DkTZDHiS.js} +87 -24
- package/dist/cjs/dom.js +85 -22
- package/dist/cjs/index.js +1 -1
- package/dist/dom.js +1 -1
- package/dist/es/render/dom/utils/unit-conversion.mjs +3 -20
- package/dist/es/render/html/HTMLVisualElement.mjs +2 -3
- package/dist/es/render/html/utils/parse-transform.mjs +83 -0
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/framer-motion.dev.js +85 -22
- 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 +3 -2
|
@@ -1106,7 +1106,7 @@
|
|
|
1106
1106
|
* This will be replaced by the build step with the latest version number.
|
|
1107
1107
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
1108
1108
|
*/
|
|
1109
|
-
this.version = "12.4.
|
|
1109
|
+
this.version = "12.4.13";
|
|
1110
1110
|
/**
|
|
1111
1111
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
1112
1112
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -1949,25 +1949,89 @@
|
|
|
1949
1949
|
}
|
|
1950
1950
|
}
|
|
1951
1951
|
|
|
1952
|
-
const
|
|
1953
|
-
const
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1952
|
+
const radToDeg = (rad) => (rad * 180) / Math.PI;
|
|
1953
|
+
const rotate = (v) => {
|
|
1954
|
+
const angle = radToDeg(Math.atan2(v[1], v[0]));
|
|
1955
|
+
return rebaseAngle(angle);
|
|
1956
|
+
};
|
|
1957
|
+
const matrix2dParsers = {
|
|
1958
|
+
x: 4,
|
|
1959
|
+
y: 5,
|
|
1960
|
+
translateX: 4,
|
|
1961
|
+
translateY: 5,
|
|
1962
|
+
scaleX: 0,
|
|
1963
|
+
scaleY: 3,
|
|
1964
|
+
scale: (v) => (Math.abs(v[0]) + Math.abs(v[3])) / 2,
|
|
1965
|
+
rotate,
|
|
1966
|
+
rotateZ: rotate,
|
|
1967
|
+
skewX: (v) => radToDeg(Math.atan(v[1])),
|
|
1968
|
+
skewY: (v) => radToDeg(Math.atan(v[2])),
|
|
1969
|
+
skew: (v) => (Math.abs(v[1]) + Math.abs(v[2])) / 2,
|
|
1970
|
+
};
|
|
1971
|
+
const rebaseAngle = (angle) => {
|
|
1972
|
+
angle = angle % 360;
|
|
1973
|
+
if (angle < 0)
|
|
1974
|
+
angle += 360;
|
|
1975
|
+
return angle;
|
|
1976
|
+
};
|
|
1977
|
+
const rotateZ = rotate;
|
|
1978
|
+
const scaleX = (v) => Math.sqrt(v[0] * v[0] + v[1] * v[1]);
|
|
1979
|
+
const scaleY = (v) => Math.sqrt(v[4] * v[4] + v[5] * v[5]);
|
|
1980
|
+
const matrix3dParsers = {
|
|
1981
|
+
x: 12,
|
|
1982
|
+
y: 13,
|
|
1983
|
+
z: 14,
|
|
1984
|
+
translateX: 12,
|
|
1985
|
+
translateY: 13,
|
|
1986
|
+
translateZ: 14,
|
|
1987
|
+
scaleX,
|
|
1988
|
+
scaleY,
|
|
1989
|
+
scale: (v) => (scaleX(v) + scaleY(v)) / 2,
|
|
1990
|
+
rotateX: (v) => rebaseAngle(radToDeg(Math.atan2(v[6], v[5]))),
|
|
1991
|
+
rotateY: (v) => rebaseAngle(radToDeg(Math.atan2(-v[2], v[0]))),
|
|
1992
|
+
rotateZ,
|
|
1993
|
+
rotate: rotateZ,
|
|
1994
|
+
skewX: (v) => radToDeg(Math.atan(v[4])),
|
|
1995
|
+
skewY: (v) => radToDeg(Math.atan(v[1])),
|
|
1996
|
+
skew: (v) => (Math.abs(v[1]) + Math.abs(v[4])) / 2,
|
|
1997
|
+
};
|
|
1998
|
+
function defaultTransformValue(name) {
|
|
1999
|
+
return name.includes("scale") ? 1 : 0;
|
|
2000
|
+
}
|
|
2001
|
+
function parseValueFromTransform(transform, name) {
|
|
2002
|
+
if (!transform || transform === "none") {
|
|
2003
|
+
return defaultTransformValue(name);
|
|
1960
2004
|
}
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
return 0;
|
|
1968
|
-
}
|
|
2005
|
+
const matrix3dMatch = transform.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);
|
|
2006
|
+
let parsers;
|
|
2007
|
+
let match;
|
|
2008
|
+
if (matrix3dMatch) {
|
|
2009
|
+
parsers = matrix3dParsers;
|
|
2010
|
+
match = matrix3dMatch;
|
|
1969
2011
|
}
|
|
2012
|
+
else {
|
|
2013
|
+
const matrix2dMatch = transform.match(/^matrix\(([-\d.e\s,]+)\)$/u);
|
|
2014
|
+
parsers = matrix2dParsers;
|
|
2015
|
+
match = matrix2dMatch;
|
|
2016
|
+
}
|
|
2017
|
+
if (!match) {
|
|
2018
|
+
return defaultTransformValue(name);
|
|
2019
|
+
}
|
|
2020
|
+
const valueParser = parsers[name];
|
|
2021
|
+
const values = match[1].split(",").map(convertTransformToNumber);
|
|
2022
|
+
return typeof valueParser === "function"
|
|
2023
|
+
? valueParser(values)
|
|
2024
|
+
: values[valueParser];
|
|
2025
|
+
}
|
|
2026
|
+
const readTransformValue = (instance, name) => {
|
|
2027
|
+
const { transform = "none" } = getComputedStyle(instance);
|
|
2028
|
+
return parseValueFromTransform(transform, name);
|
|
1970
2029
|
};
|
|
2030
|
+
function convertTransformToNumber(value) {
|
|
2031
|
+
return parseFloat(value.trim());
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
const isNumOrPxType = (v) => v === number || v === px;
|
|
1971
2035
|
const transformKeys = new Set(["x", "y", "z"]);
|
|
1972
2036
|
const nonTranslationalTransformKeys = transformPropOrder.filter((key) => !transformKeys.has(key));
|
|
1973
2037
|
function removeNonTranslationalTransform(visualElement) {
|
|
@@ -1990,8 +2054,8 @@
|
|
|
1990
2054
|
bottom: ({ y }, { top }) => parseFloat(top) + (y.max - y.min),
|
|
1991
2055
|
right: ({ x }, { left }) => parseFloat(left) + (x.max - x.min),
|
|
1992
2056
|
// Transform
|
|
1993
|
-
x:
|
|
1994
|
-
y:
|
|
2057
|
+
x: (_bbox, { transform }) => parseValueFromTransform(transform, "x"),
|
|
2058
|
+
y: (_bbox, { transform }) => parseValueFromTransform(transform, "y"),
|
|
1995
2059
|
};
|
|
1996
2060
|
// Alias translate longform names
|
|
1997
2061
|
positionalValues.translateX = positionalValues.x;
|
|
@@ -5965,7 +6029,7 @@
|
|
|
5965
6029
|
* and warn against mismatches.
|
|
5966
6030
|
*/
|
|
5967
6031
|
{
|
|
5968
|
-
warnOnce(nextValue.version === "12.4.
|
|
6032
|
+
warnOnce(nextValue.version === "12.4.13", `Attempting to mix Motion versions ${nextValue.version} with 12.4.13 may not work as expected.`);
|
|
5969
6033
|
}
|
|
5970
6034
|
}
|
|
5971
6035
|
else if (isMotionValue(prevValue)) {
|
|
@@ -7065,8 +7129,7 @@
|
|
|
7065
7129
|
}
|
|
7066
7130
|
readValueFromInstance(instance, key) {
|
|
7067
7131
|
if (transformProps.has(key)) {
|
|
7068
|
-
|
|
7069
|
-
return defaultType ? defaultType.default || 0 : 0;
|
|
7132
|
+
return readTransformValue(instance, key);
|
|
7070
7133
|
}
|
|
7071
7134
|
else {
|
|
7072
7135
|
const computedStyle = getComputedStyle$1(instance);
|