framer-motion 5.0.2 → 5.1.0-rc.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.
@@ -26,17 +26,11 @@ var svgMotionConfig = {
26
26
  height: 0,
27
27
  };
28
28
  }
29
- if (isPath(instance)) {
30
- renderState.totalPathLength = instance.getTotalLength();
31
- }
32
29
  buildSVGAttrs(renderState, latestValues, { enableHardwareAcceleration: false }, props.transformTemplate);
33
30
  // TODO: Replace with direct assignment
34
31
  renderSVG(instance, renderState);
35
32
  },
36
33
  }),
37
34
  };
38
- function isPath(element) {
39
- return element.tagName === "path";
40
- }
41
35
 
42
36
  export { svgMotionConfig };
@@ -13,7 +13,7 @@ function buildSVGAttrs(state, _a, options, transformTemplate) {
13
13
  buildHTMLStyles(state, latest, options, transformTemplate);
14
14
  state.attrs = state.style;
15
15
  state.style = {};
16
- var attrs = state.attrs, style = state.style, dimensions = state.dimensions, totalPathLength = state.totalPathLength;
16
+ var attrs = state.attrs, style = state.style, dimensions = state.dimensions;
17
17
  /**
18
18
  * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
19
19
  * and copy it into style.
@@ -33,9 +33,9 @@ function buildSVGAttrs(state, _a, options, transformTemplate) {
33
33
  attrs.x = attrX;
34
34
  if (attrY !== undefined)
35
35
  attrs.y = attrY;
36
- // Build SVG path if one has been measured
37
- if (totalPathLength !== undefined && pathLength !== undefined) {
38
- buildSVGPath(attrs, totalPathLength, pathLength, pathSpacing, pathOffset, false);
36
+ // Build SVG path if one has been defined
37
+ if (pathLength !== undefined) {
38
+ buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);
39
39
  }
40
40
  }
41
41
 
@@ -21,6 +21,7 @@ var camelCaseAttributes = new Set([
21
21
  "tableValues",
22
22
  "viewBox",
23
23
  "gradientTransform",
24
+ "pathLength",
24
25
  ]);
25
26
 
26
27
  export { camelCaseAttributes };
@@ -1,9 +1,5 @@
1
1
  import { px } from 'style-value-types';
2
2
 
3
- // Convert a progress 0-1 to a pixels value based on the provided length
4
- var progressToPixels = function (progress, length) {
5
- return px.transform(progress * length);
6
- };
7
3
  var dashKeys = {
8
4
  offset: "stroke-dashoffset",
9
5
  array: "stroke-dasharray",
@@ -19,18 +15,20 @@ var camelKeys = {
19
15
  *
20
16
  * This function is mutative to reduce per-frame GC.
21
17
  */
22
- function buildSVGPath(attrs, totalLength, length, spacing, offset, useDashCase) {
18
+ function buildSVGPath(attrs, length, spacing, offset, useDashCase) {
23
19
  if (spacing === void 0) { spacing = 1; }
24
20
  if (offset === void 0) { offset = 0; }
25
21
  if (useDashCase === void 0) { useDashCase = true; }
22
+ // Normalise path length by setting SVG attribute pathLength to 1
23
+ attrs.pathLength = 1;
26
24
  // We use dash case when setting attributes directly to the DOM node and camel case
27
25
  // when defining props on a React component.
28
26
  var keys = useDashCase ? dashKeys : camelKeys;
29
27
  // Build the dash offset
30
- attrs[keys.offset] = progressToPixels(-offset, totalLength);
28
+ attrs[keys.offset] = px.transform(-offset);
31
29
  // Build the dash array
32
- var pathLength = progressToPixels(length, totalLength);
33
- var pathSpacing = progressToPixels(spacing, totalLength);
30
+ var pathLength = px.transform(length);
31
+ var pathSpacing = px.transform(spacing);
34
32
  attrs[keys.array] = pathLength + " " + pathSpacing;
35
33
  }
36
34
 
@@ -3437,10 +3437,6 @@ function calcSVGTransformOrigin(dimensions, originX, originY) {
3437
3437
  return pxOriginX + " " + pxOriginY;
3438
3438
  }
3439
3439
 
3440
- // Convert a progress 0-1 to a pixels value based on the provided length
3441
- var progressToPixels = function (progress, length) {
3442
- return styleValueTypes.px.transform(progress * length);
3443
- };
3444
3440
  var dashKeys = {
3445
3441
  offset: "stroke-dashoffset",
3446
3442
  array: "stroke-dasharray",
@@ -3456,18 +3452,20 @@ var camelKeys = {
3456
3452
  *
3457
3453
  * This function is mutative to reduce per-frame GC.
3458
3454
  */
3459
- function buildSVGPath(attrs, totalLength, length, spacing, offset, useDashCase) {
3455
+ function buildSVGPath(attrs, length, spacing, offset, useDashCase) {
3460
3456
  if (spacing === void 0) { spacing = 1; }
3461
3457
  if (offset === void 0) { offset = 0; }
3462
3458
  if (useDashCase === void 0) { useDashCase = true; }
3459
+ // Normalise path length by setting SVG attribute pathLength to 1
3460
+ attrs.pathLength = 1;
3463
3461
  // We use dash case when setting attributes directly to the DOM node and camel case
3464
3462
  // when defining props on a React component.
3465
3463
  var keys = useDashCase ? dashKeys : camelKeys;
3466
3464
  // Build the dash offset
3467
- attrs[keys.offset] = progressToPixels(-offset, totalLength);
3465
+ attrs[keys.offset] = styleValueTypes.px.transform(-offset);
3468
3466
  // Build the dash array
3469
- var pathLength = progressToPixels(length, totalLength);
3470
- var pathSpacing = progressToPixels(spacing, totalLength);
3467
+ var pathLength = styleValueTypes.px.transform(length);
3468
+ var pathSpacing = styleValueTypes.px.transform(spacing);
3471
3469
  attrs[keys.array] = pathLength + " " + pathSpacing;
3472
3470
  }
3473
3471
 
@@ -3481,7 +3479,7 @@ function buildSVGAttrs(state, _a, options, transformTemplate) {
3481
3479
  buildHTMLStyles(state, latest, options, transformTemplate);
3482
3480
  state.attrs = state.style;
3483
3481
  state.style = {};
3484
- var attrs = state.attrs, style = state.style, dimensions = state.dimensions, totalPathLength = state.totalPathLength;
3482
+ var attrs = state.attrs, style = state.style, dimensions = state.dimensions;
3485
3483
  /**
3486
3484
  * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
3487
3485
  * and copy it into style.
@@ -3501,9 +3499,9 @@ function buildSVGAttrs(state, _a, options, transformTemplate) {
3501
3499
  attrs.x = attrX;
3502
3500
  if (attrY !== undefined)
3503
3501
  attrs.y = attrY;
3504
- // Build SVG path if one has been measured
3505
- if (totalPathLength !== undefined && pathLength !== undefined) {
3506
- buildSVGPath(attrs, totalPathLength, pathLength, pathSpacing, pathOffset, false);
3502
+ // Build SVG path if one has been defined
3503
+ if (pathLength !== undefined) {
3504
+ buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);
3507
3505
  }
3508
3506
  }
3509
3507
 
@@ -3582,6 +3580,7 @@ var camelCaseAttributes = new Set([
3582
3580
  "tableValues",
3583
3581
  "viewBox",
3584
3582
  "gradientTransform",
3583
+ "pathLength",
3585
3584
  ]);
3586
3585
 
3587
3586
  function renderSVG(element, renderState) {
@@ -3693,18 +3692,12 @@ var svgMotionConfig = {
3693
3692
  height: 0,
3694
3693
  };
3695
3694
  }
3696
- if (isPath(instance)) {
3697
- renderState.totalPathLength = instance.getTotalLength();
3698
- }
3699
3695
  buildSVGAttrs(renderState, latestValues, { enableHardwareAcceleration: false }, props.transformTemplate);
3700
3696
  // TODO: Replace with direct assignment
3701
3697
  renderSVG(instance, renderState);
3702
3698
  },
3703
3699
  }),
3704
3700
  };
3705
- function isPath(element) {
3706
- return element.tagName === "path";
3707
- }
3708
3701
 
3709
3702
  var htmlMotionConfig = {
3710
3703
  useVisualState: makeUseVisualState({
@@ -4627,10 +4627,6 @@
4627
4627
  return pxOriginX + " " + pxOriginY;
4628
4628
  }
4629
4629
 
4630
- // Convert a progress 0-1 to a pixels value based on the provided length
4631
- var progressToPixels = function (progress, length) {
4632
- return px.transform(progress * length);
4633
- };
4634
4630
  var dashKeys = {
4635
4631
  offset: "stroke-dashoffset",
4636
4632
  array: "stroke-dasharray",
@@ -4646,18 +4642,20 @@
4646
4642
  *
4647
4643
  * This function is mutative to reduce per-frame GC.
4648
4644
  */
4649
- function buildSVGPath(attrs, totalLength, length, spacing, offset, useDashCase) {
4645
+ function buildSVGPath(attrs, length, spacing, offset, useDashCase) {
4650
4646
  if (spacing === void 0) { spacing = 1; }
4651
4647
  if (offset === void 0) { offset = 0; }
4652
4648
  if (useDashCase === void 0) { useDashCase = true; }
4649
+ // Normalise path length by setting SVG attribute pathLength to 1
4650
+ attrs.pathLength = 1;
4653
4651
  // We use dash case when setting attributes directly to the DOM node and camel case
4654
4652
  // when defining props on a React component.
4655
4653
  var keys = useDashCase ? dashKeys : camelKeys;
4656
4654
  // Build the dash offset
4657
- attrs[keys.offset] = progressToPixels(-offset, totalLength);
4655
+ attrs[keys.offset] = px.transform(-offset);
4658
4656
  // Build the dash array
4659
- var pathLength = progressToPixels(length, totalLength);
4660
- var pathSpacing = progressToPixels(spacing, totalLength);
4657
+ var pathLength = px.transform(length);
4658
+ var pathSpacing = px.transform(spacing);
4661
4659
  attrs[keys.array] = pathLength + " " + pathSpacing;
4662
4660
  }
4663
4661
 
@@ -4671,7 +4669,7 @@
4671
4669
  buildHTMLStyles(state, latest, options, transformTemplate);
4672
4670
  state.attrs = state.style;
4673
4671
  state.style = {};
4674
- var attrs = state.attrs, style = state.style, dimensions = state.dimensions, totalPathLength = state.totalPathLength;
4672
+ var attrs = state.attrs, style = state.style, dimensions = state.dimensions;
4675
4673
  /**
4676
4674
  * However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
4677
4675
  * and copy it into style.
@@ -4691,9 +4689,9 @@
4691
4689
  attrs.x = attrX;
4692
4690
  if (attrY !== undefined)
4693
4691
  attrs.y = attrY;
4694
- // Build SVG path if one has been measured
4695
- if (totalPathLength !== undefined && pathLength !== undefined) {
4696
- buildSVGPath(attrs, totalPathLength, pathLength, pathSpacing, pathOffset, false);
4692
+ // Build SVG path if one has been defined
4693
+ if (pathLength !== undefined) {
4694
+ buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);
4697
4695
  }
4698
4696
  }
4699
4697
 
@@ -4772,6 +4770,7 @@
4772
4770
  "tableValues",
4773
4771
  "viewBox",
4774
4772
  "gradientTransform",
4773
+ "pathLength",
4775
4774
  ]);
4776
4775
 
4777
4776
  function renderSVG(element, renderState) {
@@ -4883,18 +4882,12 @@
4883
4882
  height: 0,
4884
4883
  };
4885
4884
  }
4886
- if (isPath(instance)) {
4887
- renderState.totalPathLength = instance.getTotalLength();
4888
- }
4889
4885
  buildSVGAttrs(renderState, latestValues, { enableHardwareAcceleration: false }, props.transformTemplate);
4890
4886
  // TODO: Replace with direct assignment
4891
4887
  renderSVG(instance, renderState);
4892
4888
  },
4893
4889
  }),
4894
4890
  };
4895
- function isPath(element) {
4896
- return element.tagName === "path";
4897
- }
4898
4891
 
4899
4892
  var htmlMotionConfig = {
4900
4893
  useVisualState: makeUseVisualState({