framer-motion 5.0.2 → 5.2.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.
- package/dist/es/motion/utils/valid-prop.mjs +1 -0
- package/dist/es/projection/node/create-projection-node.mjs +1 -1
- package/dist/es/render/dom/utils/unit-conversion.mjs +8 -1
- package/dist/es/render/svg/config-motion.mjs +0 -6
- package/dist/es/render/svg/utils/build-attrs.mjs +4 -4
- package/dist/es/render/svg/utils/camel-case-attrs.mjs +1 -0
- package/dist/es/render/svg/utils/path.mjs +6 -8
- package/dist/es/render/utils/animation-state.mjs +1 -1
- package/dist/framer-motion.cjs.js +22 -21
- package/dist/framer-motion.dev.js +75 -33
- package/dist/framer-motion.js +1 -1
- package/dist/projection.dev.js +62 -14
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/package.json +7 -6
- package/types/render/svg/types.d.ts +0 -4
- package/types/render/svg/utils/path.d.ts +1 -1
- package/dist/size-webpack-dom-animation.js +0 -1
- package/dist/size-webpack-dom-max.js +0 -2
- package/dist/size-webpack-dom-max.js.LICENSE.txt +0 -14
- package/dist/size-webpack-m.js +0 -2
- package/dist/size-webpack-m.js.LICENSE.txt +0 -14
|
@@ -307,7 +307,7 @@ function createProjectionNode(_a) {
|
|
|
307
307
|
node.updateScroll();
|
|
308
308
|
}
|
|
309
309
|
var _d = this.options, layoutId = _d.layoutId, layout = _d.layout;
|
|
310
|
-
if (
|
|
310
|
+
if (layoutId === undefined && !layout)
|
|
311
311
|
return;
|
|
312
312
|
var transformTemplate = (_c = this.options.visualElement) === null || _c === void 0 ? void 0 : _c.getProps().transformTemplate;
|
|
313
313
|
this.prevTransformTemplateValue = transformTemplate === null || transformTemplate === void 0 ? void 0 : transformTemplate(this.latestValues, "");
|
|
@@ -115,11 +115,18 @@ var convertChangedValueTypes = function (target, visualElement, changedKeys) {
|
|
|
115
115
|
var element = visualElement.getInstance();
|
|
116
116
|
var elementComputedStyle = getComputedStyle(element);
|
|
117
117
|
var display = elementComputedStyle.display;
|
|
118
|
+
var origin = {};
|
|
118
119
|
// If the element is currently set to display: "none", make it visible before
|
|
119
120
|
// measuring the target bounding box
|
|
120
121
|
if (display === "none") {
|
|
121
122
|
visualElement.setStaticValue("display", target.display || "block");
|
|
122
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Record origins before we render and update styles
|
|
126
|
+
*/
|
|
127
|
+
changedKeys.forEach(function (key) {
|
|
128
|
+
origin[key] = positionalValues[key](originBbox, elementComputedStyle);
|
|
129
|
+
});
|
|
123
130
|
// Apply the latest values (as set in checkAndConvertChangedValueTypes)
|
|
124
131
|
visualElement.syncRender();
|
|
125
132
|
var targetBbox = visualElement.measureViewportBox();
|
|
@@ -127,7 +134,7 @@ var convertChangedValueTypes = function (target, visualElement, changedKeys) {
|
|
|
127
134
|
// Restore styles to their **calculated computed style**, not their actual
|
|
128
135
|
// originally set style. This allows us to animate between equivalent pixel units.
|
|
129
136
|
var value = visualElement.getValue(key);
|
|
130
|
-
setAndResetVelocity(value,
|
|
137
|
+
setAndResetVelocity(value, origin[key]);
|
|
131
138
|
target[key] = positionalValues[key](targetBbox, elementComputedStyle);
|
|
132
139
|
});
|
|
133
140
|
return target;
|
|
@@ -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
|
|
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
|
|
37
|
-
if (
|
|
38
|
-
buildSVGPath(attrs,
|
|
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
|
|
|
@@ -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,
|
|
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] =
|
|
28
|
+
attrs[keys.offset] = px.transform(-offset);
|
|
31
29
|
// Build the dash array
|
|
32
|
-
var pathLength =
|
|
33
|
-
var pathSpacing =
|
|
30
|
+
var pathLength = px.transform(length);
|
|
31
|
+
var pathSpacing = px.transform(spacing);
|
|
34
32
|
attrs[keys.array] = pathLength + " " + pathSpacing;
|
|
35
33
|
}
|
|
36
34
|
|
|
@@ -8,10 +8,10 @@ import { isVariantLabels, resolveVariant, isVariantLabel } from './variants.mjs'
|
|
|
8
8
|
|
|
9
9
|
var variantPriorityOrder = [
|
|
10
10
|
AnimationType.Animate,
|
|
11
|
+
AnimationType.Focus,
|
|
11
12
|
AnimationType.Hover,
|
|
12
13
|
AnimationType.Tap,
|
|
13
14
|
AnimationType.Drag,
|
|
14
|
-
AnimationType.Focus,
|
|
15
15
|
AnimationType.Exit,
|
|
16
16
|
];
|
|
17
17
|
var reversePriorityOrder = __spreadArray([], __read(variantPriorityOrder), false).reverse();
|
|
@@ -1988,7 +1988,7 @@ function createProjectionNode(_a) {
|
|
|
1988
1988
|
node.updateScroll();
|
|
1989
1989
|
}
|
|
1990
1990
|
var _d = this.options, layoutId = _d.layoutId, layout = _d.layout;
|
|
1991
|
-
if (
|
|
1991
|
+
if (layoutId === undefined && !layout)
|
|
1992
1992
|
return;
|
|
1993
1993
|
var transformTemplate = (_c = this.options.visualElement) === null || _c === void 0 ? void 0 : _c.getProps().transformTemplate;
|
|
1994
1994
|
this.prevTransformTemplateValue = transformTemplate === null || transformTemplate === void 0 ? void 0 : transformTemplate(this.latestValues, "");
|
|
@@ -3348,6 +3348,7 @@ var validMotionProps = new Set([
|
|
|
3348
3348
|
"dragListener",
|
|
3349
3349
|
"dragConstraints",
|
|
3350
3350
|
"dragDirectionLock",
|
|
3351
|
+
"dragSnapToOrigin",
|
|
3351
3352
|
"_dragX",
|
|
3352
3353
|
"_dragY",
|
|
3353
3354
|
"dragElastic",
|
|
@@ -3437,10 +3438,6 @@ function calcSVGTransformOrigin(dimensions, originX, originY) {
|
|
|
3437
3438
|
return pxOriginX + " " + pxOriginY;
|
|
3438
3439
|
}
|
|
3439
3440
|
|
|
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
3441
|
var dashKeys = {
|
|
3445
3442
|
offset: "stroke-dashoffset",
|
|
3446
3443
|
array: "stroke-dasharray",
|
|
@@ -3456,18 +3453,20 @@ var camelKeys = {
|
|
|
3456
3453
|
*
|
|
3457
3454
|
* This function is mutative to reduce per-frame GC.
|
|
3458
3455
|
*/
|
|
3459
|
-
function buildSVGPath(attrs,
|
|
3456
|
+
function buildSVGPath(attrs, length, spacing, offset, useDashCase) {
|
|
3460
3457
|
if (spacing === void 0) { spacing = 1; }
|
|
3461
3458
|
if (offset === void 0) { offset = 0; }
|
|
3462
3459
|
if (useDashCase === void 0) { useDashCase = true; }
|
|
3460
|
+
// Normalise path length by setting SVG attribute pathLength to 1
|
|
3461
|
+
attrs.pathLength = 1;
|
|
3463
3462
|
// We use dash case when setting attributes directly to the DOM node and camel case
|
|
3464
3463
|
// when defining props on a React component.
|
|
3465
3464
|
var keys = useDashCase ? dashKeys : camelKeys;
|
|
3466
3465
|
// Build the dash offset
|
|
3467
|
-
attrs[keys.offset] =
|
|
3466
|
+
attrs[keys.offset] = styleValueTypes.px.transform(-offset);
|
|
3468
3467
|
// Build the dash array
|
|
3469
|
-
var pathLength =
|
|
3470
|
-
var pathSpacing =
|
|
3468
|
+
var pathLength = styleValueTypes.px.transform(length);
|
|
3469
|
+
var pathSpacing = styleValueTypes.px.transform(spacing);
|
|
3471
3470
|
attrs[keys.array] = pathLength + " " + pathSpacing;
|
|
3472
3471
|
}
|
|
3473
3472
|
|
|
@@ -3481,7 +3480,7 @@ function buildSVGAttrs(state, _a, options, transformTemplate) {
|
|
|
3481
3480
|
buildHTMLStyles(state, latest, options, transformTemplate);
|
|
3482
3481
|
state.attrs = state.style;
|
|
3483
3482
|
state.style = {};
|
|
3484
|
-
var attrs = state.attrs, style = state.style, dimensions = state.dimensions
|
|
3483
|
+
var attrs = state.attrs, style = state.style, dimensions = state.dimensions;
|
|
3485
3484
|
/**
|
|
3486
3485
|
* However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
|
|
3487
3486
|
* and copy it into style.
|
|
@@ -3501,9 +3500,9 @@ function buildSVGAttrs(state, _a, options, transformTemplate) {
|
|
|
3501
3500
|
attrs.x = attrX;
|
|
3502
3501
|
if (attrY !== undefined)
|
|
3503
3502
|
attrs.y = attrY;
|
|
3504
|
-
// Build SVG path if one has been
|
|
3505
|
-
if (
|
|
3506
|
-
buildSVGPath(attrs,
|
|
3503
|
+
// Build SVG path if one has been defined
|
|
3504
|
+
if (pathLength !== undefined) {
|
|
3505
|
+
buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);
|
|
3507
3506
|
}
|
|
3508
3507
|
}
|
|
3509
3508
|
|
|
@@ -3582,6 +3581,7 @@ var camelCaseAttributes = new Set([
|
|
|
3582
3581
|
"tableValues",
|
|
3583
3582
|
"viewBox",
|
|
3584
3583
|
"gradientTransform",
|
|
3584
|
+
"pathLength",
|
|
3585
3585
|
]);
|
|
3586
3586
|
|
|
3587
3587
|
function renderSVG(element, renderState) {
|
|
@@ -3693,18 +3693,12 @@ var svgMotionConfig = {
|
|
|
3693
3693
|
height: 0,
|
|
3694
3694
|
};
|
|
3695
3695
|
}
|
|
3696
|
-
if (isPath(instance)) {
|
|
3697
|
-
renderState.totalPathLength = instance.getTotalLength();
|
|
3698
|
-
}
|
|
3699
3696
|
buildSVGAttrs(renderState, latestValues, { enableHardwareAcceleration: false }, props.transformTemplate);
|
|
3700
3697
|
// TODO: Replace with direct assignment
|
|
3701
3698
|
renderSVG(instance, renderState);
|
|
3702
3699
|
},
|
|
3703
3700
|
}),
|
|
3704
3701
|
};
|
|
3705
|
-
function isPath(element) {
|
|
3706
|
-
return element.tagName === "path";
|
|
3707
|
-
}
|
|
3708
3702
|
|
|
3709
3703
|
var htmlMotionConfig = {
|
|
3710
3704
|
useVisualState: makeUseVisualState({
|
|
@@ -4413,10 +4407,10 @@ function shouldBlockAnimation(_a, key) {
|
|
|
4413
4407
|
|
|
4414
4408
|
var variantPriorityOrder = [
|
|
4415
4409
|
AnimationType.Animate,
|
|
4410
|
+
AnimationType.Focus,
|
|
4416
4411
|
AnimationType.Hover,
|
|
4417
4412
|
AnimationType.Tap,
|
|
4418
4413
|
AnimationType.Drag,
|
|
4419
|
-
AnimationType.Focus,
|
|
4420
4414
|
AnimationType.Exit,
|
|
4421
4415
|
];
|
|
4422
4416
|
var reversePriorityOrder = tslib.__spreadArray([], tslib.__read(variantPriorityOrder), false).reverse();
|
|
@@ -6238,11 +6232,18 @@ var convertChangedValueTypes = function (target, visualElement, changedKeys) {
|
|
|
6238
6232
|
var element = visualElement.getInstance();
|
|
6239
6233
|
var elementComputedStyle = getComputedStyle(element);
|
|
6240
6234
|
var display = elementComputedStyle.display;
|
|
6235
|
+
var origin = {};
|
|
6241
6236
|
// If the element is currently set to display: "none", make it visible before
|
|
6242
6237
|
// measuring the target bounding box
|
|
6243
6238
|
if (display === "none") {
|
|
6244
6239
|
visualElement.setStaticValue("display", target.display || "block");
|
|
6245
6240
|
}
|
|
6241
|
+
/**
|
|
6242
|
+
* Record origins before we render and update styles
|
|
6243
|
+
*/
|
|
6244
|
+
changedKeys.forEach(function (key) {
|
|
6245
|
+
origin[key] = positionalValues[key](originBbox, elementComputedStyle);
|
|
6246
|
+
});
|
|
6246
6247
|
// Apply the latest values (as set in checkAndConvertChangedValueTypes)
|
|
6247
6248
|
visualElement.syncRender();
|
|
6248
6249
|
var targetBbox = visualElement.measureViewportBox();
|
|
@@ -6250,7 +6251,7 @@ var convertChangedValueTypes = function (target, visualElement, changedKeys) {
|
|
|
6250
6251
|
// Restore styles to their **calculated computed style**, not their actual
|
|
6251
6252
|
// originally set style. This allows us to animate between equivalent pixel units.
|
|
6252
6253
|
var value = visualElement.getValue(key);
|
|
6253
|
-
setAndResetVelocity(value,
|
|
6254
|
+
setAndResetVelocity(value, origin[key]);
|
|
6254
6255
|
target[key] = positionalValues[key](targetBbox, elementComputedStyle);
|
|
6255
6256
|
});
|
|
6256
6257
|
return target;
|
|
@@ -929,6 +929,46 @@
|
|
|
929
929
|
return functions ? functions.map(applyDefaultFilter).join(' ') : v;
|
|
930
930
|
} });
|
|
931
931
|
|
|
932
|
+
function hueToRgb(p, q, t) {
|
|
933
|
+
if (t < 0)
|
|
934
|
+
t += 1;
|
|
935
|
+
if (t > 1)
|
|
936
|
+
t -= 1;
|
|
937
|
+
if (t < 1 / 6)
|
|
938
|
+
return p + (q - p) * 6 * t;
|
|
939
|
+
if (t < 1 / 2)
|
|
940
|
+
return q;
|
|
941
|
+
if (t < 2 / 3)
|
|
942
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
943
|
+
return p;
|
|
944
|
+
}
|
|
945
|
+
function hslaToRgba({ hue, saturation, lightness, alpha }) {
|
|
946
|
+
hue /= 360;
|
|
947
|
+
saturation /= 100;
|
|
948
|
+
lightness /= 100;
|
|
949
|
+
let red = 0;
|
|
950
|
+
let green = 0;
|
|
951
|
+
let blue = 0;
|
|
952
|
+
if (!saturation) {
|
|
953
|
+
red = green = blue = lightness;
|
|
954
|
+
}
|
|
955
|
+
else {
|
|
956
|
+
const q = lightness < 0.5
|
|
957
|
+
? lightness * (1 + saturation)
|
|
958
|
+
: lightness + saturation - lightness * saturation;
|
|
959
|
+
const p = 2 * lightness - q;
|
|
960
|
+
red = hueToRgb(p, q, hue + 1 / 3);
|
|
961
|
+
green = hueToRgb(p, q, hue);
|
|
962
|
+
blue = hueToRgb(p, q, hue - 1 / 3);
|
|
963
|
+
}
|
|
964
|
+
return {
|
|
965
|
+
red: Math.round(red * 255),
|
|
966
|
+
green: Math.round(green * 255),
|
|
967
|
+
blue: Math.round(blue * 255),
|
|
968
|
+
alpha,
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
|
|
932
972
|
const mixLinearColor = (from, to, v) => {
|
|
933
973
|
const fromExpo = from * from;
|
|
934
974
|
const toExpo = to * to;
|
|
@@ -938,24 +978,25 @@
|
|
|
938
978
|
const getColorType = (v) => colorTypes.find((type) => type.test(v));
|
|
939
979
|
const notAnimatable = (color) => `'${color}' is not an animatable color. Use the equivalent color code instead.`;
|
|
940
980
|
const mixColor = (from, to) => {
|
|
941
|
-
|
|
942
|
-
|
|
981
|
+
let fromColorType = getColorType(from);
|
|
982
|
+
let toColorType = getColorType(to);
|
|
943
983
|
invariant(!!fromColorType, notAnimatable(from));
|
|
944
984
|
invariant(!!toColorType, notAnimatable(to));
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
|
|
985
|
+
let fromColor = fromColorType.parse(from);
|
|
986
|
+
let toColor = toColorType.parse(to);
|
|
987
|
+
if (fromColorType === hsla) {
|
|
988
|
+
fromColor = hslaToRgba(fromColor);
|
|
989
|
+
fromColorType = rgba;
|
|
990
|
+
}
|
|
991
|
+
if (toColorType === hsla) {
|
|
992
|
+
toColor = hslaToRgba(toColor);
|
|
993
|
+
toColorType = rgba;
|
|
994
|
+
}
|
|
953
995
|
const blended = Object.assign({}, fromColor);
|
|
954
|
-
const mixFunc = fromColorType === hsla ? mix : mixLinearColor;
|
|
955
996
|
return (v) => {
|
|
956
997
|
for (const key in blended) {
|
|
957
998
|
if (key !== "alpha") {
|
|
958
|
-
blended[key] =
|
|
999
|
+
blended[key] = mixLinearColor(fromColor[key], toColor[key], v);
|
|
959
1000
|
}
|
|
960
1001
|
}
|
|
961
1002
|
blended.alpha = mix(fromColor.alpha, toColor.alpha, v);
|
|
@@ -3178,7 +3219,7 @@
|
|
|
3178
3219
|
node.updateScroll();
|
|
3179
3220
|
}
|
|
3180
3221
|
var _d = this.options, layoutId = _d.layoutId, layout = _d.layout;
|
|
3181
|
-
if (
|
|
3222
|
+
if (layoutId === undefined && !layout)
|
|
3182
3223
|
return;
|
|
3183
3224
|
var transformTemplate = (_c = this.options.visualElement) === null || _c === void 0 ? void 0 : _c.getProps().transformTemplate;
|
|
3184
3225
|
this.prevTransformTemplateValue = transformTemplate === null || transformTemplate === void 0 ? void 0 : transformTemplate(this.latestValues, "");
|
|
@@ -4538,6 +4579,7 @@
|
|
|
4538
4579
|
"dragListener",
|
|
4539
4580
|
"dragConstraints",
|
|
4540
4581
|
"dragDirectionLock",
|
|
4582
|
+
"dragSnapToOrigin",
|
|
4541
4583
|
"_dragX",
|
|
4542
4584
|
"_dragY",
|
|
4543
4585
|
"dragElastic",
|
|
@@ -4627,10 +4669,6 @@
|
|
|
4627
4669
|
return pxOriginX + " " + pxOriginY;
|
|
4628
4670
|
}
|
|
4629
4671
|
|
|
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
4672
|
var dashKeys = {
|
|
4635
4673
|
offset: "stroke-dashoffset",
|
|
4636
4674
|
array: "stroke-dasharray",
|
|
@@ -4646,18 +4684,20 @@
|
|
|
4646
4684
|
*
|
|
4647
4685
|
* This function is mutative to reduce per-frame GC.
|
|
4648
4686
|
*/
|
|
4649
|
-
function buildSVGPath(attrs,
|
|
4687
|
+
function buildSVGPath(attrs, length, spacing, offset, useDashCase) {
|
|
4650
4688
|
if (spacing === void 0) { spacing = 1; }
|
|
4651
4689
|
if (offset === void 0) { offset = 0; }
|
|
4652
4690
|
if (useDashCase === void 0) { useDashCase = true; }
|
|
4691
|
+
// Normalise path length by setting SVG attribute pathLength to 1
|
|
4692
|
+
attrs.pathLength = 1;
|
|
4653
4693
|
// We use dash case when setting attributes directly to the DOM node and camel case
|
|
4654
4694
|
// when defining props on a React component.
|
|
4655
4695
|
var keys = useDashCase ? dashKeys : camelKeys;
|
|
4656
4696
|
// Build the dash offset
|
|
4657
|
-
attrs[keys.offset] =
|
|
4697
|
+
attrs[keys.offset] = px.transform(-offset);
|
|
4658
4698
|
// Build the dash array
|
|
4659
|
-
var pathLength =
|
|
4660
|
-
var pathSpacing =
|
|
4699
|
+
var pathLength = px.transform(length);
|
|
4700
|
+
var pathSpacing = px.transform(spacing);
|
|
4661
4701
|
attrs[keys.array] = pathLength + " " + pathSpacing;
|
|
4662
4702
|
}
|
|
4663
4703
|
|
|
@@ -4671,7 +4711,7 @@
|
|
|
4671
4711
|
buildHTMLStyles(state, latest, options, transformTemplate);
|
|
4672
4712
|
state.attrs = state.style;
|
|
4673
4713
|
state.style = {};
|
|
4674
|
-
var attrs = state.attrs, style = state.style, dimensions = state.dimensions
|
|
4714
|
+
var attrs = state.attrs, style = state.style, dimensions = state.dimensions;
|
|
4675
4715
|
/**
|
|
4676
4716
|
* However, we apply transforms as CSS transforms. So if we detect a transform we take it from attrs
|
|
4677
4717
|
* and copy it into style.
|
|
@@ -4691,9 +4731,9 @@
|
|
|
4691
4731
|
attrs.x = attrX;
|
|
4692
4732
|
if (attrY !== undefined)
|
|
4693
4733
|
attrs.y = attrY;
|
|
4694
|
-
// Build SVG path if one has been
|
|
4695
|
-
if (
|
|
4696
|
-
buildSVGPath(attrs,
|
|
4734
|
+
// Build SVG path if one has been defined
|
|
4735
|
+
if (pathLength !== undefined) {
|
|
4736
|
+
buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);
|
|
4697
4737
|
}
|
|
4698
4738
|
}
|
|
4699
4739
|
|
|
@@ -4772,6 +4812,7 @@
|
|
|
4772
4812
|
"tableValues",
|
|
4773
4813
|
"viewBox",
|
|
4774
4814
|
"gradientTransform",
|
|
4815
|
+
"pathLength",
|
|
4775
4816
|
]);
|
|
4776
4817
|
|
|
4777
4818
|
function renderSVG(element, renderState) {
|
|
@@ -4883,18 +4924,12 @@
|
|
|
4883
4924
|
height: 0,
|
|
4884
4925
|
};
|
|
4885
4926
|
}
|
|
4886
|
-
if (isPath(instance)) {
|
|
4887
|
-
renderState.totalPathLength = instance.getTotalLength();
|
|
4888
|
-
}
|
|
4889
4927
|
buildSVGAttrs(renderState, latestValues, { enableHardwareAcceleration: false }, props.transformTemplate);
|
|
4890
4928
|
// TODO: Replace with direct assignment
|
|
4891
4929
|
renderSVG(instance, renderState);
|
|
4892
4930
|
},
|
|
4893
4931
|
}),
|
|
4894
4932
|
};
|
|
4895
|
-
function isPath(element) {
|
|
4896
|
-
return element.tagName === "path";
|
|
4897
|
-
}
|
|
4898
4933
|
|
|
4899
4934
|
var htmlMotionConfig = {
|
|
4900
4935
|
useVisualState: makeUseVisualState({
|
|
@@ -5603,10 +5638,10 @@
|
|
|
5603
5638
|
|
|
5604
5639
|
var variantPriorityOrder = [
|
|
5605
5640
|
AnimationType.Animate,
|
|
5641
|
+
AnimationType.Focus,
|
|
5606
5642
|
AnimationType.Hover,
|
|
5607
5643
|
AnimationType.Tap,
|
|
5608
5644
|
AnimationType.Drag,
|
|
5609
|
-
AnimationType.Focus,
|
|
5610
5645
|
AnimationType.Exit,
|
|
5611
5646
|
];
|
|
5612
5647
|
var reversePriorityOrder = __spreadArray([], __read(variantPriorityOrder), false).reverse();
|
|
@@ -7428,11 +7463,18 @@
|
|
|
7428
7463
|
var element = visualElement.getInstance();
|
|
7429
7464
|
var elementComputedStyle = getComputedStyle(element);
|
|
7430
7465
|
var display = elementComputedStyle.display;
|
|
7466
|
+
var origin = {};
|
|
7431
7467
|
// If the element is currently set to display: "none", make it visible before
|
|
7432
7468
|
// measuring the target bounding box
|
|
7433
7469
|
if (display === "none") {
|
|
7434
7470
|
visualElement.setStaticValue("display", target.display || "block");
|
|
7435
7471
|
}
|
|
7472
|
+
/**
|
|
7473
|
+
* Record origins before we render and update styles
|
|
7474
|
+
*/
|
|
7475
|
+
changedKeys.forEach(function (key) {
|
|
7476
|
+
origin[key] = positionalValues[key](originBbox, elementComputedStyle);
|
|
7477
|
+
});
|
|
7436
7478
|
// Apply the latest values (as set in checkAndConvertChangedValueTypes)
|
|
7437
7479
|
visualElement.syncRender();
|
|
7438
7480
|
var targetBbox = visualElement.measureViewportBox();
|
|
@@ -7440,7 +7482,7 @@
|
|
|
7440
7482
|
// Restore styles to their **calculated computed style**, not their actual
|
|
7441
7483
|
// originally set style. This allows us to animate between equivalent pixel units.
|
|
7442
7484
|
var value = visualElement.getValue(key);
|
|
7443
|
-
setAndResetVelocity(value,
|
|
7485
|
+
setAndResetVelocity(value, origin[key]);
|
|
7444
7486
|
target[key] = positionalValues[key](targetBbox, elementComputedStyle);
|
|
7445
7487
|
});
|
|
7446
7488
|
return target;
|