framer-motion 12.11.4 → 12.12.0
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-t9legXtK.js → create-BiMCrvDh.js} +75 -78
- package/dist/cjs/dom-mini.js +1 -3
- package/dist/cjs/dom.js +15 -17
- package/dist/cjs/index.js +15 -53
- package/dist/cjs/m.js +113 -115
- package/dist/dom.js +1 -1
- package/dist/es/animation/animate/single-value.mjs +1 -2
- package/dist/es/animation/animate/subject.mjs +1 -1
- package/dist/es/animation/sequence/create.mjs +1 -2
- package/dist/es/components/Reorder/Item.mjs +1 -1
- package/dist/es/index.mjs +0 -1
- package/dist/es/render/VisualElement.mjs +1 -2
- package/dist/es/render/dom/DOMVisualElement.mjs +1 -2
- package/dist/es/render/dom/use-render.mjs +2 -2
- package/dist/es/render/html/use-props.mjs +1 -1
- package/dist/es/render/html/utils/scrape-motion-values.mjs +1 -1
- package/dist/es/render/svg/utils/scrape-motion-values.mjs +1 -2
- package/dist/es/render/utils/motion-values.mjs +1 -2
- package/dist/es/value/use-motion-template.mjs +1 -1
- package/dist/es/value/use-spring.mjs +12 -52
- package/dist/es/value/use-will-change/is.mjs +1 -1
- package/dist/es/value/utils/resolve-motion-value.mjs +1 -1
- package/dist/framer-motion.dev.js +141 -110
- package/dist/framer-motion.js +1 -1
- package/dist/m.d.ts +3 -3
- package/dist/size-rollup-animate.js +1 -1
- package/dist/size-rollup-dom-animation-assets.js +1 -1
- package/dist/size-rollup-dom-animation-m.js +1 -1
- package/dist/size-rollup-dom-max-assets.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/types/client.d.ts +1 -1
- package/dist/types/index.d.ts +7 -9
- package/dist/{types.d-CQt5spQA.d.ts → types.d-CtuPurYT.d.ts} +3 -3
- package/package.json +3 -3
- package/dist/es/value/utils/is-motion-value.mjs +0 -3
package/dist/cjs/client.js
CHANGED
|
@@ -156,8 +156,6 @@ function calcRelativePosition(target, layout, parent) {
|
|
|
156
156
|
calcRelativeAxisPosition(target.y, layout.y, parent.y);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
const isMotionValue = (value) => Boolean(value && value.getVelocity);
|
|
160
|
-
|
|
161
159
|
const isNotNull = (value) => value !== null;
|
|
162
160
|
function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe) {
|
|
163
161
|
const resolvedKeyframes = keyframes.filter(isNotNull);
|
|
@@ -307,7 +305,7 @@ const animateMotionValue = (name, value, target, transition = {}, element, isHan
|
|
|
307
305
|
};
|
|
308
306
|
|
|
309
307
|
function animateSingleValue(value, keyframes, options) {
|
|
310
|
-
const motionValue = isMotionValue(value) ? value : motionDom.motionValue(value);
|
|
308
|
+
const motionValue = motionDom.isMotionValue(value) ? value : motionDom.motionValue(value);
|
|
311
309
|
motionValue.start(animateMotionValue("", motionValue, keyframes, options));
|
|
312
310
|
return motionValue.animation;
|
|
313
311
|
}
|
|
@@ -372,7 +370,7 @@ function delay(callback, timeout) {
|
|
|
372
370
|
* TODO: Remove and move to library
|
|
373
371
|
*/
|
|
374
372
|
function resolveMotionValue(value) {
|
|
375
|
-
return isMotionValue(value) ? value.get() : value;
|
|
373
|
+
return motionDom.isMotionValue(value) ? value.get() : value;
|
|
376
374
|
}
|
|
377
375
|
|
|
378
376
|
const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
|
|
@@ -2713,14 +2711,14 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
2713
2711
|
for (const key in next) {
|
|
2714
2712
|
const nextValue = next[key];
|
|
2715
2713
|
const prevValue = prev[key];
|
|
2716
|
-
if (isMotionValue(nextValue)) {
|
|
2714
|
+
if (motionDom.isMotionValue(nextValue)) {
|
|
2717
2715
|
/**
|
|
2718
2716
|
* If this is a motion value found in props or style, we want to add it
|
|
2719
2717
|
* to our visual element's motion value map.
|
|
2720
2718
|
*/
|
|
2721
2719
|
element.addValue(key, nextValue);
|
|
2722
2720
|
}
|
|
2723
|
-
else if (isMotionValue(prevValue)) {
|
|
2721
|
+
else if (motionDom.isMotionValue(prevValue)) {
|
|
2724
2722
|
/**
|
|
2725
2723
|
* If we're swapping from a motion value to a static value,
|
|
2726
2724
|
* create a new motion value from that
|
|
@@ -2916,7 +2914,7 @@ class VisualElement {
|
|
|
2916
2914
|
const { willChange, ...initialMotionValues } = this.scrapeMotionValuesFromProps(props, {}, this);
|
|
2917
2915
|
for (const key in initialMotionValues) {
|
|
2918
2916
|
const value = initialMotionValues[key];
|
|
2919
|
-
if (latestValues[key] !== undefined && isMotionValue(value)) {
|
|
2917
|
+
if (latestValues[key] !== undefined && motionDom.isMotionValue(value)) {
|
|
2920
2918
|
value.set(latestValues[key], false);
|
|
2921
2919
|
}
|
|
2922
2920
|
}
|
|
@@ -3187,9 +3185,9 @@ class VisualElement {
|
|
|
3187
3185
|
else if (!motionDom.findValueType(value) && motionDom.complex.test(target)) {
|
|
3188
3186
|
value = motionDom.getAnimatableNone(key, target);
|
|
3189
3187
|
}
|
|
3190
|
-
this.setBaseTarget(key, isMotionValue(value) ? value.get() : value);
|
|
3188
|
+
this.setBaseTarget(key, motionDom.isMotionValue(value) ? value.get() : value);
|
|
3191
3189
|
}
|
|
3192
|
-
return isMotionValue(value) ? value.get() : value;
|
|
3190
|
+
return motionDom.isMotionValue(value) ? value.get() : value;
|
|
3193
3191
|
}
|
|
3194
3192
|
/**
|
|
3195
3193
|
* Set the base target to later animate back to. This is currently
|
|
@@ -3222,7 +3220,7 @@ class VisualElement {
|
|
|
3222
3220
|
* so we can read the value from an alternative source, try that.
|
|
3223
3221
|
*/
|
|
3224
3222
|
const target = this.getBaseTargetFromProps(this.props, key);
|
|
3225
|
-
if (target !== undefined && !isMotionValue(target))
|
|
3223
|
+
if (target !== undefined && !motionDom.isMotionValue(target))
|
|
3226
3224
|
return target;
|
|
3227
3225
|
/**
|
|
3228
3226
|
* If the value was initially defined on initial, but it doesn't any more,
|
|
@@ -3274,7 +3272,7 @@ class DOMVisualElement extends VisualElement {
|
|
|
3274
3272
|
delete this.childSubscription;
|
|
3275
3273
|
}
|
|
3276
3274
|
const { children } = this.props;
|
|
3277
|
-
if (isMotionValue(children)) {
|
|
3275
|
+
if (motionDom.isMotionValue(children)) {
|
|
3278
3276
|
this.childSubscription = children.on("change", (latest) => {
|
|
3279
3277
|
if (this.current) {
|
|
3280
3278
|
this.current.textContent = `${latest}`;
|
|
@@ -3418,9 +3416,9 @@ function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
|
|
|
3418
3416
|
const { style } = props;
|
|
3419
3417
|
const newValues = {};
|
|
3420
3418
|
for (const key in style) {
|
|
3421
|
-
if (isMotionValue(style[key]) ||
|
|
3419
|
+
if (motionDom.isMotionValue(style[key]) ||
|
|
3422
3420
|
(prevProps.style &&
|
|
3423
|
-
isMotionValue(prevProps.style[key])) ||
|
|
3421
|
+
motionDom.isMotionValue(prevProps.style[key])) ||
|
|
3424
3422
|
isForcedMotionValue(key, props) ||
|
|
3425
3423
|
visualElement?.getValue(key)?.liveStyle !== undefined) {
|
|
3426
3424
|
newValues[key] = style[key];
|
|
@@ -3622,7 +3620,7 @@ function setTarget(visualElement, definition) {
|
|
|
3622
3620
|
}
|
|
3623
3621
|
|
|
3624
3622
|
function isWillChangeMotionValue(value) {
|
|
3625
|
-
return Boolean(isMotionValue(value) && value.add);
|
|
3623
|
+
return Boolean(motionDom.isMotionValue(value) && value.add);
|
|
3626
3624
|
}
|
|
3627
3625
|
|
|
3628
3626
|
function addValueToWillChange(visualElement, key) {
|
|
@@ -5715,7 +5713,7 @@ const createHtmlRenderState = () => ({
|
|
|
5715
5713
|
|
|
5716
5714
|
function copyRawValuesOnly(target, source, props) {
|
|
5717
5715
|
for (const key in source) {
|
|
5718
|
-
if (!isMotionValue(source[key]) && !isForcedMotionValue(key, props)) {
|
|
5716
|
+
if (!motionDom.isMotionValue(source[key]) && !isForcedMotionValue(key, props)) {
|
|
5719
5717
|
target[key] = source[key];
|
|
5720
5718
|
}
|
|
5721
5719
|
}
|
|
@@ -5763,65 +5761,6 @@ function useHTMLProps(props, visualState) {
|
|
|
5763
5761
|
return htmlProps;
|
|
5764
5762
|
}
|
|
5765
5763
|
|
|
5766
|
-
/**
|
|
5767
|
-
* We keep these listed separately as we use the lowercase tag names as part
|
|
5768
|
-
* of the runtime bundle to detect SVG components
|
|
5769
|
-
*/
|
|
5770
|
-
const lowercaseSVGElements = [
|
|
5771
|
-
"animate",
|
|
5772
|
-
"circle",
|
|
5773
|
-
"defs",
|
|
5774
|
-
"desc",
|
|
5775
|
-
"ellipse",
|
|
5776
|
-
"g",
|
|
5777
|
-
"image",
|
|
5778
|
-
"line",
|
|
5779
|
-
"filter",
|
|
5780
|
-
"marker",
|
|
5781
|
-
"mask",
|
|
5782
|
-
"metadata",
|
|
5783
|
-
"path",
|
|
5784
|
-
"pattern",
|
|
5785
|
-
"polygon",
|
|
5786
|
-
"polyline",
|
|
5787
|
-
"rect",
|
|
5788
|
-
"stop",
|
|
5789
|
-
"switch",
|
|
5790
|
-
"symbol",
|
|
5791
|
-
"svg",
|
|
5792
|
-
"text",
|
|
5793
|
-
"tspan",
|
|
5794
|
-
"use",
|
|
5795
|
-
"view",
|
|
5796
|
-
];
|
|
5797
|
-
|
|
5798
|
-
function isSVGComponent(Component) {
|
|
5799
|
-
if (
|
|
5800
|
-
/**
|
|
5801
|
-
* If it's not a string, it's a custom React component. Currently we only support
|
|
5802
|
-
* HTML custom React components.
|
|
5803
|
-
*/
|
|
5804
|
-
typeof Component !== "string" ||
|
|
5805
|
-
/**
|
|
5806
|
-
* If it contains a dash, the element is a custom HTML webcomponent.
|
|
5807
|
-
*/
|
|
5808
|
-
Component.includes("-")) {
|
|
5809
|
-
return false;
|
|
5810
|
-
}
|
|
5811
|
-
else if (
|
|
5812
|
-
/**
|
|
5813
|
-
* If it's in our list of lowercase SVG tags, it's an SVG component
|
|
5814
|
-
*/
|
|
5815
|
-
lowercaseSVGElements.indexOf(Component) > -1 ||
|
|
5816
|
-
/**
|
|
5817
|
-
* If it contains a capital letter, it's an SVG component
|
|
5818
|
-
*/
|
|
5819
|
-
/[A-Z]/u.test(Component)) {
|
|
5820
|
-
return true;
|
|
5821
|
-
}
|
|
5822
|
-
return false;
|
|
5823
|
-
}
|
|
5824
|
-
|
|
5825
5764
|
const dashKeys = {
|
|
5826
5765
|
offset: "stroke-dashoffset",
|
|
5827
5766
|
array: "stroke-dasharray",
|
|
@@ -5928,6 +5867,65 @@ function useSVGProps(props, visualState, _isStatic, Component) {
|
|
|
5928
5867
|
return visualProps;
|
|
5929
5868
|
}
|
|
5930
5869
|
|
|
5870
|
+
/**
|
|
5871
|
+
* We keep these listed separately as we use the lowercase tag names as part
|
|
5872
|
+
* of the runtime bundle to detect SVG components
|
|
5873
|
+
*/
|
|
5874
|
+
const lowercaseSVGElements = [
|
|
5875
|
+
"animate",
|
|
5876
|
+
"circle",
|
|
5877
|
+
"defs",
|
|
5878
|
+
"desc",
|
|
5879
|
+
"ellipse",
|
|
5880
|
+
"g",
|
|
5881
|
+
"image",
|
|
5882
|
+
"line",
|
|
5883
|
+
"filter",
|
|
5884
|
+
"marker",
|
|
5885
|
+
"mask",
|
|
5886
|
+
"metadata",
|
|
5887
|
+
"path",
|
|
5888
|
+
"pattern",
|
|
5889
|
+
"polygon",
|
|
5890
|
+
"polyline",
|
|
5891
|
+
"rect",
|
|
5892
|
+
"stop",
|
|
5893
|
+
"switch",
|
|
5894
|
+
"symbol",
|
|
5895
|
+
"svg",
|
|
5896
|
+
"text",
|
|
5897
|
+
"tspan",
|
|
5898
|
+
"use",
|
|
5899
|
+
"view",
|
|
5900
|
+
];
|
|
5901
|
+
|
|
5902
|
+
function isSVGComponent(Component) {
|
|
5903
|
+
if (
|
|
5904
|
+
/**
|
|
5905
|
+
* If it's not a string, it's a custom React component. Currently we only support
|
|
5906
|
+
* HTML custom React components.
|
|
5907
|
+
*/
|
|
5908
|
+
typeof Component !== "string" ||
|
|
5909
|
+
/**
|
|
5910
|
+
* If it contains a dash, the element is a custom HTML webcomponent.
|
|
5911
|
+
*/
|
|
5912
|
+
Component.includes("-")) {
|
|
5913
|
+
return false;
|
|
5914
|
+
}
|
|
5915
|
+
else if (
|
|
5916
|
+
/**
|
|
5917
|
+
* If it's in our list of lowercase SVG tags, it's an SVG component
|
|
5918
|
+
*/
|
|
5919
|
+
lowercaseSVGElements.indexOf(Component) > -1 ||
|
|
5920
|
+
/**
|
|
5921
|
+
* If it contains a capital letter, it's an SVG component
|
|
5922
|
+
*/
|
|
5923
|
+
/[A-Z]/u.test(Component)) {
|
|
5924
|
+
return true;
|
|
5925
|
+
}
|
|
5926
|
+
return false;
|
|
5927
|
+
}
|
|
5928
|
+
|
|
5931
5929
|
function createUseRender(forwardMotionProps = false) {
|
|
5932
5930
|
const useRender = (Component, props, ref, { latestValues }, isStatic) => {
|
|
5933
5931
|
const useVisualProps = isSVGComponent(Component)
|
|
@@ -5944,7 +5942,7 @@ function createUseRender(forwardMotionProps = false) {
|
|
|
5944
5942
|
* will be handled by the onChange handler
|
|
5945
5943
|
*/
|
|
5946
5944
|
const { children } = props;
|
|
5947
|
-
const renderedChildren = React.useMemo(() => (isMotionValue(children) ? children.get() : children), [children]);
|
|
5945
|
+
const renderedChildren = React.useMemo(() => (motionDom.isMotionValue(children) ? children.get() : children), [children]);
|
|
5948
5946
|
return React.createElement(Component, {
|
|
5949
5947
|
...elementProps,
|
|
5950
5948
|
children: renderedChildren,
|
|
@@ -6032,8 +6030,8 @@ const htmlMotionConfig = {
|
|
|
6032
6030
|
function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
|
|
6033
6031
|
const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
|
|
6034
6032
|
for (const key in props) {
|
|
6035
|
-
if (isMotionValue(props[key]) ||
|
|
6036
|
-
isMotionValue(prevProps[key])) {
|
|
6033
|
+
if (motionDom.isMotionValue(props[key]) ||
|
|
6034
|
+
motionDom.isMotionValue(prevProps[key])) {
|
|
6037
6035
|
const targetKey = motionDom.transformPropOrder.indexOf(key) !== -1
|
|
6038
6036
|
? "attr" + key.charAt(0).toUpperCase() + key.substring(1)
|
|
6039
6037
|
: key;
|
|
@@ -6185,7 +6183,6 @@ exports.getOptimisedAppearId = getOptimisedAppearId;
|
|
|
6185
6183
|
exports.hasReducedMotionListener = hasReducedMotionListener;
|
|
6186
6184
|
exports.initPrefersReducedMotion = initPrefersReducedMotion;
|
|
6187
6185
|
exports.isBrowser = isBrowser;
|
|
6188
|
-
exports.isMotionValue = isMotionValue;
|
|
6189
6186
|
exports.isSVGElement = isSVGElement;
|
|
6190
6187
|
exports.isValidMotionProp = isValidMotionProp;
|
|
6191
6188
|
exports.layout = layout;
|
package/dist/cjs/dom-mini.js
CHANGED
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var motionDom = require('motion-dom');
|
|
6
6
|
var motionUtils = require('motion-utils');
|
|
7
7
|
|
|
8
|
-
const isMotionValue = (value) => Boolean(value && value.getVelocity);
|
|
9
|
-
|
|
10
8
|
function isDOMKeyframes(keyframes) {
|
|
11
9
|
return typeof keyframes === "object" && !Array.isArray(keyframes);
|
|
12
10
|
}
|
|
@@ -229,7 +227,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
229
227
|
maxDuration = Math.max(calculatedDelay + duration, maxDuration);
|
|
230
228
|
totalDuration = Math.max(targetTime, totalDuration);
|
|
231
229
|
};
|
|
232
|
-
if (isMotionValue(subject)) {
|
|
230
|
+
if (motionDom.isMotionValue(subject)) {
|
|
233
231
|
const subjectSequence = getSubjectSequence(subject, sequences);
|
|
234
232
|
resolveValueSequence(keyframes, transition, getValueSequence("default", subjectSequence));
|
|
235
233
|
}
|
package/dist/cjs/dom.js
CHANGED
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var motionDom = require('motion-dom');
|
|
6
6
|
var motionUtils = require('motion-utils');
|
|
7
7
|
|
|
8
|
-
const isMotionValue = (value) => Boolean(value && value.getVelocity);
|
|
9
|
-
|
|
10
8
|
function isDOMKeyframes(keyframes) {
|
|
11
9
|
return typeof keyframes === "object" && !Array.isArray(keyframes);
|
|
12
10
|
}
|
|
@@ -229,7 +227,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
229
227
|
maxDuration = Math.max(calculatedDelay + duration, maxDuration);
|
|
230
228
|
totalDuration = Math.max(targetTime, totalDuration);
|
|
231
229
|
};
|
|
232
|
-
if (isMotionValue(subject)) {
|
|
230
|
+
if (motionDom.isMotionValue(subject)) {
|
|
233
231
|
const subjectSequence = getSubjectSequence(subject, sequences);
|
|
234
232
|
resolveValueSequence(keyframes, transition, getValueSequence("default", subjectSequence));
|
|
235
233
|
}
|
|
@@ -412,7 +410,7 @@ function setTarget(visualElement, definition) {
|
|
|
412
410
|
}
|
|
413
411
|
|
|
414
412
|
function isWillChangeMotionValue(value) {
|
|
415
|
-
return Boolean(isMotionValue(value) && value.add);
|
|
413
|
+
return Boolean(motionDom.isMotionValue(value) && value.add);
|
|
416
414
|
}
|
|
417
415
|
|
|
418
416
|
function addValueToWillChange(visualElement, key) {
|
|
@@ -794,14 +792,14 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
794
792
|
for (const key in next) {
|
|
795
793
|
const nextValue = next[key];
|
|
796
794
|
const prevValue = prev[key];
|
|
797
|
-
if (isMotionValue(nextValue)) {
|
|
795
|
+
if (motionDom.isMotionValue(nextValue)) {
|
|
798
796
|
/**
|
|
799
797
|
* If this is a motion value found in props or style, we want to add it
|
|
800
798
|
* to our visual element's motion value map.
|
|
801
799
|
*/
|
|
802
800
|
element.addValue(key, nextValue);
|
|
803
801
|
}
|
|
804
|
-
else if (isMotionValue(prevValue)) {
|
|
802
|
+
else if (motionDom.isMotionValue(prevValue)) {
|
|
805
803
|
/**
|
|
806
804
|
* If we're swapping from a motion value to a static value,
|
|
807
805
|
* create a new motion value from that
|
|
@@ -962,7 +960,7 @@ class VisualElement {
|
|
|
962
960
|
const { willChange, ...initialMotionValues } = this.scrapeMotionValuesFromProps(props, {}, this);
|
|
963
961
|
for (const key in initialMotionValues) {
|
|
964
962
|
const value = initialMotionValues[key];
|
|
965
|
-
if (latestValues[key] !== undefined && isMotionValue(value)) {
|
|
963
|
+
if (latestValues[key] !== undefined && motionDom.isMotionValue(value)) {
|
|
966
964
|
value.set(latestValues[key], false);
|
|
967
965
|
}
|
|
968
966
|
}
|
|
@@ -1233,9 +1231,9 @@ class VisualElement {
|
|
|
1233
1231
|
else if (!motionDom.findValueType(value) && motionDom.complex.test(target)) {
|
|
1234
1232
|
value = motionDom.getAnimatableNone(key, target);
|
|
1235
1233
|
}
|
|
1236
|
-
this.setBaseTarget(key, isMotionValue(value) ? value.get() : value);
|
|
1234
|
+
this.setBaseTarget(key, motionDom.isMotionValue(value) ? value.get() : value);
|
|
1237
1235
|
}
|
|
1238
|
-
return isMotionValue(value) ? value.get() : value;
|
|
1236
|
+
return motionDom.isMotionValue(value) ? value.get() : value;
|
|
1239
1237
|
}
|
|
1240
1238
|
/**
|
|
1241
1239
|
* Set the base target to later animate back to. This is currently
|
|
@@ -1268,7 +1266,7 @@ class VisualElement {
|
|
|
1268
1266
|
* so we can read the value from an alternative source, try that.
|
|
1269
1267
|
*/
|
|
1270
1268
|
const target = this.getBaseTargetFromProps(this.props, key);
|
|
1271
|
-
if (target !== undefined && !isMotionValue(target))
|
|
1269
|
+
if (target !== undefined && !motionDom.isMotionValue(target))
|
|
1272
1270
|
return target;
|
|
1273
1271
|
/**
|
|
1274
1272
|
* If the value was initially defined on initial, but it doesn't any more,
|
|
@@ -1320,7 +1318,7 @@ class DOMVisualElement extends VisualElement {
|
|
|
1320
1318
|
delete this.childSubscription;
|
|
1321
1319
|
}
|
|
1322
1320
|
const { children } = this.props;
|
|
1323
|
-
if (isMotionValue(children)) {
|
|
1321
|
+
if (motionDom.isMotionValue(children)) {
|
|
1324
1322
|
this.childSubscription = children.on("change", (latest) => {
|
|
1325
1323
|
if (this.current) {
|
|
1326
1324
|
this.current.textContent = `${latest}`;
|
|
@@ -1466,9 +1464,9 @@ function scrapeMotionValuesFromProps$1(props, prevProps, visualElement) {
|
|
|
1466
1464
|
const { style } = props;
|
|
1467
1465
|
const newValues = {};
|
|
1468
1466
|
for (const key in style) {
|
|
1469
|
-
if (isMotionValue(style[key]) ||
|
|
1467
|
+
if (motionDom.isMotionValue(style[key]) ||
|
|
1470
1468
|
(prevProps.style &&
|
|
1471
|
-
isMotionValue(prevProps.style[key])) ||
|
|
1469
|
+
motionDom.isMotionValue(prevProps.style[key])) ||
|
|
1472
1470
|
isForcedMotionValue(key, props) ||
|
|
1473
1471
|
visualElement?.getValue(key)?.liveStyle !== undefined) {
|
|
1474
1472
|
newValues[key] = style[key];
|
|
@@ -1671,8 +1669,8 @@ function renderSVG(element, renderState, _styleProp, projection) {
|
|
|
1671
1669
|
function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
|
|
1672
1670
|
const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
|
|
1673
1671
|
for (const key in props) {
|
|
1674
|
-
if (isMotionValue(props[key]) ||
|
|
1675
|
-
isMotionValue(prevProps[key])) {
|
|
1672
|
+
if (motionDom.isMotionValue(props[key]) ||
|
|
1673
|
+
motionDom.isMotionValue(prevProps[key])) {
|
|
1676
1674
|
const targetKey = motionDom.transformPropOrder.indexOf(key) !== -1
|
|
1677
1675
|
? "attr" + key.charAt(0).toUpperCase() + key.substring(1)
|
|
1678
1676
|
: key;
|
|
@@ -1753,13 +1751,13 @@ function createObjectVisualElement(subject) {
|
|
|
1753
1751
|
}
|
|
1754
1752
|
|
|
1755
1753
|
function animateSingleValue(value, keyframes, options) {
|
|
1756
|
-
const motionValue = isMotionValue(value) ? value : motionDom.motionValue(value);
|
|
1754
|
+
const motionValue = motionDom.isMotionValue(value) ? value : motionDom.motionValue(value);
|
|
1757
1755
|
motionValue.start(animateMotionValue("", motionValue, keyframes, options));
|
|
1758
1756
|
return motionValue.animation;
|
|
1759
1757
|
}
|
|
1760
1758
|
|
|
1761
1759
|
function isSingleValue(subject, keyframes) {
|
|
1762
|
-
return (isMotionValue(subject) ||
|
|
1760
|
+
return (motionDom.isMotionValue(subject) ||
|
|
1763
1761
|
typeof subject === "number" ||
|
|
1764
1762
|
(typeof subject === "string" && !isDOMKeyframes(keyframes)));
|
|
1765
1763
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var create = require('./create-
|
|
7
|
+
var create = require('./create-BiMCrvDh.js');
|
|
8
8
|
var motionDom = require('motion-dom');
|
|
9
9
|
var motionUtils = require('motion-utils');
|
|
10
10
|
|
|
@@ -709,7 +709,7 @@ function useListTransform(values, transformer) {
|
|
|
709
709
|
}
|
|
710
710
|
|
|
711
711
|
function useDefaultMotionValue(value, defaultValue = 0) {
|
|
712
|
-
return
|
|
712
|
+
return motionDom.isMotionValue(value) ? value : useMotionValue(defaultValue);
|
|
713
713
|
}
|
|
714
714
|
function ReorderItemComponent({ children, style = {}, value, as = "li", onDrag, layout = true, ...props }, externalRef) {
|
|
715
715
|
const Component = create.useConstant(() => motion[as]);
|
|
@@ -958,7 +958,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
958
958
|
maxDuration = Math.max(calculatedDelay + duration, maxDuration);
|
|
959
959
|
totalDuration = Math.max(targetTime, totalDuration);
|
|
960
960
|
};
|
|
961
|
-
if (
|
|
961
|
+
if (motionDom.isMotionValue(subject)) {
|
|
962
962
|
const subjectSequence = getSubjectSequence(subject, sequences);
|
|
963
963
|
resolveValueSequence(keyframes, transition, getValueSequence("default", subjectSequence));
|
|
964
964
|
}
|
|
@@ -1143,7 +1143,7 @@ function createObjectVisualElement(subject) {
|
|
|
1143
1143
|
}
|
|
1144
1144
|
|
|
1145
1145
|
function isSingleValue(subject, keyframes) {
|
|
1146
|
-
return (
|
|
1146
|
+
return (motionDom.isMotionValue(subject) ||
|
|
1147
1147
|
typeof subject === "number" ||
|
|
1148
1148
|
(typeof subject === "string" && !isDOMKeyframes(keyframes)));
|
|
1149
1149
|
}
|
|
@@ -2048,64 +2048,27 @@ function useMotionTemplate(fragments, ...values) {
|
|
|
2048
2048
|
output += fragments[i];
|
|
2049
2049
|
const value = values[i];
|
|
2050
2050
|
if (value) {
|
|
2051
|
-
output +=
|
|
2051
|
+
output += motionDom.isMotionValue(value) ? value.get() : value;
|
|
2052
2052
|
}
|
|
2053
2053
|
}
|
|
2054
2054
|
return output;
|
|
2055
2055
|
}
|
|
2056
|
-
return useCombineMotionValues(values.filter(
|
|
2056
|
+
return useCombineMotionValues(values.filter(motionDom.isMotionValue), buildValue);
|
|
2057
2057
|
}
|
|
2058
2058
|
|
|
2059
|
-
function useSpring(source,
|
|
2059
|
+
function useSpring(source, options = {}) {
|
|
2060
2060
|
const { isStatic } = React.useContext(create.MotionConfigContext);
|
|
2061
|
-
const
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
const value = useMotionValue(
|
|
2067
|
-
const latestValue = React.useRef(initialValue);
|
|
2068
|
-
const latestSetter = React.useRef(motionUtils.noop);
|
|
2069
|
-
const startAnimation = () => {
|
|
2070
|
-
stopAnimation();
|
|
2071
|
-
activeSpringAnimation.current = new motionDom.JSAnimation({
|
|
2072
|
-
keyframes: [asNumber(value.get()), asNumber(latestValue.current)],
|
|
2073
|
-
velocity: value.getVelocity(),
|
|
2074
|
-
type: "spring",
|
|
2075
|
-
restDelta: 0.001,
|
|
2076
|
-
restSpeed: 0.01,
|
|
2077
|
-
...config,
|
|
2078
|
-
onUpdate: latestSetter.current,
|
|
2079
|
-
});
|
|
2080
|
-
};
|
|
2081
|
-
const stopAnimation = () => {
|
|
2082
|
-
if (activeSpringAnimation.current) {
|
|
2083
|
-
activeSpringAnimation.current.stop();
|
|
2084
|
-
}
|
|
2085
|
-
};
|
|
2061
|
+
const getFromSource = () => (motionDom.isMotionValue(source) ? source.get() : source);
|
|
2062
|
+
// isStatic will never change, allowing early hooks return
|
|
2063
|
+
if (isStatic) {
|
|
2064
|
+
return useTransform(getFromSource);
|
|
2065
|
+
}
|
|
2066
|
+
const value = useMotionValue(getFromSource());
|
|
2086
2067
|
React.useInsertionEffect(() => {
|
|
2087
|
-
return
|
|
2088
|
-
|
|
2089
|
-
return set(v);
|
|
2090
|
-
latestValue.current = v;
|
|
2091
|
-
latestSetter.current = (latest) => set(parseValue(latest, unit));
|
|
2092
|
-
motionDom.frame.postRender(startAnimation);
|
|
2093
|
-
return value.get();
|
|
2094
|
-
}, stopAnimation);
|
|
2095
|
-
}, [JSON.stringify(config)]);
|
|
2096
|
-
create.useIsomorphicLayoutEffect(() => {
|
|
2097
|
-
if (create.isMotionValue(source)) {
|
|
2098
|
-
return source.on("change", (v) => value.set(parseValue(v, unit)));
|
|
2099
|
-
}
|
|
2100
|
-
}, [value, unit]);
|
|
2068
|
+
return motionDom.attachSpring(value, source, options);
|
|
2069
|
+
}, [value, JSON.stringify(options)]);
|
|
2101
2070
|
return value;
|
|
2102
2071
|
}
|
|
2103
|
-
function parseValue(v, unit) {
|
|
2104
|
-
return unit ? v + unit : v;
|
|
2105
|
-
}
|
|
2106
|
-
function asNumber(v) {
|
|
2107
|
-
return typeof v === "number" ? v : parseFloat(v);
|
|
2108
|
-
}
|
|
2109
2072
|
|
|
2110
2073
|
function useAnimationFrame(callback) {
|
|
2111
2074
|
const initialTimestamp = React.useRef(0);
|
|
@@ -2962,7 +2925,6 @@ exports.distance = create.distance;
|
|
|
2962
2925
|
exports.distance2D = create.distance2D;
|
|
2963
2926
|
exports.filterProps = create.filterProps;
|
|
2964
2927
|
exports.isBrowser = create.isBrowser;
|
|
2965
|
-
exports.isMotionValue = create.isMotionValue;
|
|
2966
2928
|
exports.isValidMotionProp = create.isValidMotionProp;
|
|
2967
2929
|
exports.makeUseVisualState = create.makeUseVisualState;
|
|
2968
2930
|
exports.optimizedAppearDataAttribute = create.optimizedAppearDataAttribute;
|