framer-motion 5.5.6 → 5.5.7

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/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
- var useMotionValue = require('./use-motion-value-3615b5bb.js');
6
+ var useMotionValue = require('./use-motion-value-1c6ad062.js');
7
7
  var React = require('react');
8
8
  var styleValueTypes = require('style-value-types');
9
9
  var popmotion = require('popmotion');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
- var useMotionValue = require('./use-motion-value-3615b5bb.js');
6
+ var useMotionValue = require('./use-motion-value-1c6ad062.js');
7
7
  var React = require('react');
8
8
  var popmotion = require('popmotion');
9
9
  var three = require('three');
@@ -1139,6 +1139,12 @@ function animate(from, to, transition) {
1139
1139
 
1140
1140
  var borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
1141
1141
  var numBorders = borders.length;
1142
+ var asNumber = function (value) {
1143
+ return typeof value === "string" ? parseFloat(value) : value;
1144
+ };
1145
+ var isPx = function (value) {
1146
+ return typeof value === "number" || styleValueTypes.px.test(value);
1147
+ };
1142
1148
  function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
1143
1149
  var _a, _b, _c, _d;
1144
1150
  if (shouldCrossfadeOpacity) {
@@ -1162,15 +1168,17 @@ function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnl
1162
1168
  continue;
1163
1169
  followRadius || (followRadius = 0);
1164
1170
  leadRadius || (leadRadius = 0);
1165
- /**
1166
- * Currently we're only crossfading between numerical border radius.
1167
- * It would be possible to crossfade between percentages for a little
1168
- * extra bundle size.
1169
- */
1170
- if (typeof followRadius === "number" &&
1171
- typeof leadRadius === "number") {
1172
- var radius = Math.max(popmotion.mix(followRadius, leadRadius, progress), 0);
1173
- target[borderLabel] = radius;
1171
+ var canMix = followRadius === 0 ||
1172
+ leadRadius === 0 ||
1173
+ isPx(followRadius) === isPx(leadRadius);
1174
+ if (canMix) {
1175
+ target[borderLabel] = Math.max(popmotion.mix(asNumber(followRadius), asNumber(leadRadius), progress), 0);
1176
+ if (styleValueTypes.percent.test(leadRadius) || styleValueTypes.percent.test(followRadius)) {
1177
+ target[borderLabel] += "%";
1178
+ }
1179
+ }
1180
+ else {
1181
+ target[borderLabel] = leadRadius;
1174
1182
  }
1175
1183
  }
1176
1184
  /**
@@ -1,7 +1,14 @@
1
1
  import { mix, progress, linear, circOut } from 'popmotion';
2
+ import { px, percent } from 'style-value-types';
2
3
 
3
4
  var borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
4
5
  var numBorders = borders.length;
6
+ var asNumber = function (value) {
7
+ return typeof value === "string" ? parseFloat(value) : value;
8
+ };
9
+ var isPx = function (value) {
10
+ return typeof value === "number" || px.test(value);
11
+ };
5
12
  function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
6
13
  var _a, _b, _c, _d;
7
14
  if (shouldCrossfadeOpacity) {
@@ -25,15 +32,17 @@ function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnl
25
32
  continue;
26
33
  followRadius || (followRadius = 0);
27
34
  leadRadius || (leadRadius = 0);
28
- /**
29
- * Currently we're only crossfading between numerical border radius.
30
- * It would be possible to crossfade between percentages for a little
31
- * extra bundle size.
32
- */
33
- if (typeof followRadius === "number" &&
34
- typeof leadRadius === "number") {
35
- var radius = Math.max(mix(followRadius, leadRadius, progress), 0);
36
- target[borderLabel] = radius;
35
+ var canMix = followRadius === 0 ||
36
+ leadRadius === 0 ||
37
+ isPx(followRadius) === isPx(leadRadius);
38
+ if (canMix) {
39
+ target[borderLabel] = Math.max(mix(asNumber(followRadius), asNumber(leadRadius), progress), 0);
40
+ if (percent.test(leadRadius) || percent.test(followRadius)) {
41
+ target[borderLabel] += "%";
42
+ }
43
+ }
44
+ else {
45
+ target[borderLabel] = leadRadius;
37
46
  }
38
47
  }
39
48
  /**
@@ -2374,6 +2374,12 @@
2374
2374
 
2375
2375
  var borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
2376
2376
  var numBorders = borders.length;
2377
+ var asNumber = function (value) {
2378
+ return typeof value === "string" ? parseFloat(value) : value;
2379
+ };
2380
+ var isPx = function (value) {
2381
+ return typeof value === "number" || px.test(value);
2382
+ };
2377
2383
  function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
2378
2384
  var _a, _b, _c, _d;
2379
2385
  if (shouldCrossfadeOpacity) {
@@ -2397,15 +2403,17 @@
2397
2403
  continue;
2398
2404
  followRadius || (followRadius = 0);
2399
2405
  leadRadius || (leadRadius = 0);
2400
- /**
2401
- * Currently we're only crossfading between numerical border radius.
2402
- * It would be possible to crossfade between percentages for a little
2403
- * extra bundle size.
2404
- */
2405
- if (typeof followRadius === "number" &&
2406
- typeof leadRadius === "number") {
2407
- var radius = Math.max(mix(followRadius, leadRadius, progress), 0);
2408
- target[borderLabel] = radius;
2406
+ var canMix = followRadius === 0 ||
2407
+ leadRadius === 0 ||
2408
+ isPx(followRadius) === isPx(leadRadius);
2409
+ if (canMix) {
2410
+ target[borderLabel] = Math.max(mix(asNumber(followRadius), asNumber(leadRadius), progress), 0);
2411
+ if (percent.test(leadRadius) || percent.test(followRadius)) {
2412
+ target[borderLabel] += "%";
2413
+ }
2414
+ }
2415
+ else {
2416
+ target[borderLabel] = leadRadius;
2409
2417
  }
2410
2418
  }
2411
2419
  /**