framer-motion 7.7.0 → 7.7.1

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.
Files changed (62) hide show
  1. package/dist/cjs/index.js +529 -155
  2. package/dist/es/animation/legacy-popmotion/index.mjs +1 -1
  3. package/dist/es/animation/legacy-popmotion/inertia.mjs +2 -2
  4. package/dist/es/animation/utils/is-animatable.mjs +1 -1
  5. package/dist/es/frameloop/create-render-step.mjs +88 -0
  6. package/dist/es/frameloop/data.mjs +6 -0
  7. package/dist/es/frameloop/index.mjs +59 -0
  8. package/dist/es/frameloop/on-next-frame.mjs +12 -0
  9. package/dist/es/gestures/PanSession.mjs +4 -3
  10. package/dist/es/gestures/drag/VisualElementDragControls.mjs +1 -1
  11. package/dist/es/motion/features/layout/MeasureLayout.mjs +1 -1
  12. package/dist/es/projection/animation/mix-values.mjs +1 -1
  13. package/dist/es/projection/geometry/delta-remove.mjs +1 -1
  14. package/dist/es/projection/node/create-projection-node.mjs +1 -1
  15. package/dist/es/projection/styles/scale-border-radius.mjs +1 -1
  16. package/dist/es/projection/styles/scale-box-shadow.mjs +1 -1
  17. package/dist/es/render/VisualElement.mjs +1 -1
  18. package/dist/es/render/dom/utils/unit-conversion.mjs +2 -1
  19. package/dist/es/render/dom/value-types/animatable-none.mjs +2 -1
  20. package/dist/es/render/dom/value-types/defaults.mjs +2 -1
  21. package/dist/es/render/dom/value-types/dimensions.mjs +2 -1
  22. package/dist/es/render/dom/value-types/find.mjs +2 -1
  23. package/dist/es/render/dom/value-types/number.mjs +2 -1
  24. package/dist/es/render/dom/value-types/type-int.mjs +1 -1
  25. package/dist/es/render/svg/utils/path.mjs +1 -1
  26. package/dist/es/render/svg/utils/transform-origin.mjs +1 -1
  27. package/dist/es/render/utils/motion-values.mjs +1 -1
  28. package/dist/es/render/utils/setters.mjs +1 -1
  29. package/dist/es/utils/delay.mjs +1 -1
  30. package/dist/es/utils/interpolate.mjs +1 -1
  31. package/dist/es/utils/mix-color.mjs +4 -1
  32. package/dist/es/utils/mix-complex.mjs +5 -24
  33. package/dist/es/utils/use-animation-frame.mjs +1 -1
  34. package/dist/es/utils/use-force-update.mjs +1 -1
  35. package/dist/es/utils/use-instant-transition.mjs +1 -1
  36. package/dist/es/value/index.mjs +4 -3
  37. package/dist/es/value/types/color/hex.mjs +40 -0
  38. package/dist/es/value/types/color/hsla.mjs +22 -0
  39. package/dist/es/value/types/color/index.mjs +28 -0
  40. package/dist/es/value/types/color/rgba.mjs +25 -0
  41. package/dist/es/value/types/color/utils.mjs +23 -0
  42. package/dist/es/value/types/complex/filter.mjs +30 -0
  43. package/dist/es/value/types/complex/index.mjs +61 -0
  44. package/dist/es/value/types/numbers/index.mjs +17 -0
  45. package/dist/es/value/types/numbers/units.mjs +19 -0
  46. package/dist/es/value/types/utils.mjs +15 -0
  47. package/dist/es/value/use-combine-values.mjs +1 -1
  48. package/dist/framer-motion.dev.js +284 -230
  49. package/dist/framer-motion.js +1 -1
  50. package/dist/index.d.ts +7 -2
  51. package/dist/projection.dev.js +5451 -5397
  52. package/dist/size-rollup-dom-animation-assets.js +1 -1
  53. package/dist/size-rollup-dom-animation.js +1 -1
  54. package/dist/size-rollup-dom-max-assets.js +1 -1
  55. package/dist/size-rollup-dom-max.js +1 -1
  56. package/dist/size-rollup-m.js +1 -1
  57. package/dist/size-rollup-motion.js +1 -1
  58. package/dist/size-webpack-dom-animation.js +1 -1
  59. package/dist/size-webpack-dom-max.js +1 -1
  60. package/dist/size-webpack-m.js +1 -1
  61. package/dist/three-entry.d.ts +7 -2
  62. package/package.json +9 -11
@@ -0,0 +1,25 @@
1
+ import { clamp } from '../../../utils/clamp.mjs';
2
+ import { number, alpha } from '../numbers/index.mjs';
3
+ import { sanitize } from '../utils.mjs';
4
+ import { isColorString, splitColor } from './utils.mjs';
5
+
6
+ const clampRgbUnit = (v) => clamp(0, 255, v);
7
+ const rgbUnit = {
8
+ ...number,
9
+ transform: (v) => Math.round(clampRgbUnit(v)),
10
+ };
11
+ const rgba = {
12
+ test: isColorString("rgb", "red"),
13
+ parse: splitColor("red", "green", "blue"),
14
+ transform: ({ red, green, blue, alpha: alpha$1 = 1 }) => "rgba(" +
15
+ rgbUnit.transform(red) +
16
+ ", " +
17
+ rgbUnit.transform(green) +
18
+ ", " +
19
+ rgbUnit.transform(blue) +
20
+ ", " +
21
+ sanitize(alpha.transform(alpha$1)) +
22
+ ")",
23
+ };
24
+
25
+ export { rgbUnit, rgba };
@@ -0,0 +1,23 @@
1
+ import { isString, singleColorRegex, floatRegex } from '../utils.mjs';
2
+
3
+ /**
4
+ * Returns true if the provided string is a color, ie rgba(0,0,0,0) or #000,
5
+ * but false if a number or multiple colors
6
+ */
7
+ const isColorString = (type, testProp) => (v) => {
8
+ return Boolean((isString(v) && singleColorRegex.test(v) && v.startsWith(type)) ||
9
+ (testProp && Object.prototype.hasOwnProperty.call(v, testProp)));
10
+ };
11
+ const splitColor = (aName, bName, cName) => (v) => {
12
+ if (!isString(v))
13
+ return v;
14
+ const [a, b, c, alpha] = v.match(floatRegex);
15
+ return {
16
+ [aName]: parseFloat(a),
17
+ [bName]: parseFloat(b),
18
+ [cName]: parseFloat(c),
19
+ alpha: alpha !== undefined ? parseFloat(alpha) : 1,
20
+ };
21
+ };
22
+
23
+ export { isColorString, splitColor };
@@ -0,0 +1,30 @@
1
+ import { complex } from './index.mjs';
2
+ import { floatRegex } from '../utils.mjs';
3
+
4
+ /**
5
+ * Properties that should default to 1 or 100%
6
+ */
7
+ const maxDefaults = new Set(["brightness", "contrast", "saturate", "opacity"]);
8
+ function applyDefaultFilter(v) {
9
+ const [name, value] = v.slice(0, -1).split("(");
10
+ if (name === "drop-shadow")
11
+ return v;
12
+ const [number] = value.match(floatRegex) || [];
13
+ if (!number)
14
+ return v;
15
+ const unit = value.replace(number, "");
16
+ let defaultValue = maxDefaults.has(name) ? 1 : 0;
17
+ if (number !== value)
18
+ defaultValue *= 100;
19
+ return name + "(" + defaultValue + unit + ")";
20
+ }
21
+ const functionRegex = /([a-z-]*)\(.*?\)/g;
22
+ const filter = {
23
+ ...complex,
24
+ getAnimatableNone: (v) => {
25
+ const functions = v.match(functionRegex);
26
+ return functions ? functions.map(applyDefaultFilter).join(" ") : v;
27
+ },
28
+ };
29
+
30
+ export { filter };
@@ -0,0 +1,61 @@
1
+ import { color } from '../color/index.mjs';
2
+ import { number } from '../numbers/index.mjs';
3
+ import { isString, floatRegex, colorRegex, sanitize } from '../utils.mjs';
4
+
5
+ const colorToken = "${c}";
6
+ const numberToken = "${n}";
7
+ function test(v) {
8
+ var _a, _b, _c, _d;
9
+ return (isNaN(v) &&
10
+ isString(v) &&
11
+ ((_b = (_a = v.match(floatRegex)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) +
12
+ ((_d = (_c = v.match(colorRegex)) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) >
13
+ 0);
14
+ }
15
+ function analyseComplexValue(v) {
16
+ if (typeof v === "number")
17
+ v = `${v}`;
18
+ const values = [];
19
+ let numColors = 0;
20
+ let numNumbers = 0;
21
+ const colors = v.match(colorRegex);
22
+ if (colors) {
23
+ numColors = colors.length;
24
+ // Strip colors from input so they're not picked up by number regex.
25
+ // There's a better way to combine these regex searches, but its beyond my regex skills
26
+ v = v.replace(colorRegex, colorToken);
27
+ values.push(...colors.map(color.parse));
28
+ }
29
+ const numbers = v.match(floatRegex);
30
+ if (numbers) {
31
+ numNumbers = numbers.length;
32
+ v = v.replace(floatRegex, numberToken);
33
+ values.push(...numbers.map(number.parse));
34
+ }
35
+ return { values, numColors, numNumbers, tokenised: v };
36
+ }
37
+ function parse(v) {
38
+ return analyseComplexValue(v).values;
39
+ }
40
+ function createTransformer(source) {
41
+ const { values, numColors, tokenised } = analyseComplexValue(source);
42
+ const numValues = values.length;
43
+ return (v) => {
44
+ let output = tokenised;
45
+ for (let i = 0; i < numValues; i++) {
46
+ output = output.replace(i < numColors ? colorToken : numberToken, i < numColors
47
+ ? color.transform(v[i])
48
+ : sanitize(v[i]));
49
+ }
50
+ return output;
51
+ };
52
+ }
53
+ const convertNumbersToZero = (v) => typeof v === "number" ? 0 : v;
54
+ function getAnimatableNone(v) {
55
+ const parsed = parse(v);
56
+ const transformer = createTransformer(v);
57
+ return transformer(parsed.map(convertNumbersToZero));
58
+ }
59
+ const complex = { test, parse, createTransformer, getAnimatableNone };
60
+
61
+ export { analyseComplexValue, complex };
@@ -0,0 +1,17 @@
1
+ import { clamp } from '../../../utils/clamp.mjs';
2
+
3
+ const number = {
4
+ test: (v) => typeof v === "number",
5
+ parse: parseFloat,
6
+ transform: (v) => v,
7
+ };
8
+ const alpha = {
9
+ ...number,
10
+ transform: (v) => clamp(0, 1, v),
11
+ };
12
+ const scale = {
13
+ ...number,
14
+ default: 1,
15
+ };
16
+
17
+ export { alpha, number, scale };
@@ -0,0 +1,19 @@
1
+ import { isString } from '../utils.mjs';
2
+
3
+ const createUnitType = (unit) => ({
4
+ test: (v) => isString(v) && v.endsWith(unit) && v.split(" ").length === 1,
5
+ parse: parseFloat,
6
+ transform: (v) => `${v}${unit}`,
7
+ });
8
+ const degrees = createUnitType("deg");
9
+ const percent = createUnitType("%");
10
+ const px = createUnitType("px");
11
+ const vh = createUnitType("vh");
12
+ const vw = createUnitType("vw");
13
+ const progressPercentage = {
14
+ ...percent,
15
+ parse: (v) => percent.parse(v) / 100,
16
+ transform: (v) => percent.transform(v * 100),
17
+ };
18
+
19
+ export { degrees, percent, progressPercentage, px, vh, vw };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * TODO: When we move from string as a source of truth to data models
3
+ * everything in this folder should probably be referred to as models vs types
4
+ */
5
+ // If this number is a decimal, make it just five decimal places
6
+ // to avoid exponents
7
+ const sanitize = (v) => Math.round(v * 100000) / 100000;
8
+ const floatRegex = /(-)?([\d]*\.?[\d])+/g;
9
+ const colorRegex = /(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi;
10
+ const singleColorRegex = /^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;
11
+ function isString(v) {
12
+ return typeof v === "string";
13
+ }
14
+
15
+ export { colorRegex, floatRegex, isString, sanitize, singleColorRegex };
@@ -1,6 +1,6 @@
1
1
  import { useMotionValue } from './use-motion-value.mjs';
2
2
  import { useMultiOnChange } from './use-on-change.mjs';
3
- import sync, { cancelSync } from 'framesync';
3
+ import { cancelSync, sync } from '../frameloop/index.mjs';
4
4
 
5
5
  function useCombineMotionValues(values, combineValues) {
6
6
  /**