framer-motion 9.1.0 → 9.1.2
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/README.md +15 -15
- package/dist/cjs/index.js +605 -116
- package/dist/es/animation/hooks/animation-controls.mjs +1 -1
- package/dist/es/animation/index.mjs +1 -1
- package/dist/es/animation/legacy-popmotion/find-spring.mjs +1 -1
- package/dist/es/animation/legacy-popmotion/keyframes.mjs +3 -8
- package/dist/es/animation/utils/easing.mjs +1 -1
- package/dist/es/components/AnimateSharedLayout.mjs +2 -2
- package/dist/es/components/Reorder/Group.mjs +1 -1
- package/dist/es/components/Reorder/Item.mjs +1 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +3 -4
- package/dist/es/gestures/focus.mjs +2 -3
- package/dist/es/gestures/hover.mjs +1 -2
- package/dist/es/gestures/press.mjs +2 -3
- package/dist/es/index.mjs +1 -0
- package/dist/es/motion/features/animation/exit.mjs +1 -2
- package/dist/es/motion/features/viewport/index.mjs +2 -3
- package/dist/es/render/VisualElement.mjs +3 -4
- package/dist/es/render/dom/resize/handle-element.mjs +64 -0
- package/dist/es/render/dom/resize/handle-window.mjs +30 -0
- package/dist/es/render/dom/resize/index.mjs +8 -0
- package/dist/es/render/dom/scroll/index.mjs +74 -0
- package/dist/es/render/dom/scroll/info.mjs +56 -0
- package/dist/es/render/dom/scroll/offsets/edge.mjs +45 -0
- package/dist/es/render/dom/scroll/offsets/index.mjs +54 -0
- package/dist/es/render/dom/scroll/offsets/inset.mjs +25 -0
- package/dist/es/render/dom/scroll/offsets/offset.mjs +35 -0
- package/dist/es/render/dom/scroll/offsets/presets.mjs +20 -0
- package/dist/es/render/dom/scroll/on-scroll-handler.mjs +38 -0
- package/dist/es/render/dom/utils/css-variables-conversion.mjs +5 -7
- package/dist/es/render/dom/utils/is-css-variable.mjs +4 -7
- package/dist/es/render/dom/utils/resolve-element.mjs +21 -0
- package/dist/es/render/dom/utils/unit-conversion.mjs +2 -11
- package/dist/es/render/dom/viewport/index.mjs +52 -0
- package/dist/es/render/html/HTMLVisualElement.mjs +2 -2
- package/dist/es/render/html/utils/build-styles.mjs +2 -2
- package/dist/es/render/utils/animation-state.mjs +16 -21
- package/dist/es/render/utils/is-controlling-variants.mjs +1 -10
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/render/utils/variant-props.mjs +12 -0
- package/dist/es/utils/errors.mjs +18 -0
- package/dist/es/utils/interpolate.mjs +1 -1
- package/dist/es/utils/mix-color.mjs +1 -1
- package/dist/es/utils/mix-complex.mjs +1 -1
- package/dist/es/utils/offsets/default.mjs +9 -0
- package/dist/es/utils/offsets/fill.mjs +12 -0
- package/dist/es/utils/offsets/time.mjs +5 -0
- package/dist/es/utils/use-in-view.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/es/value/use-inverted-scale.mjs +1 -1
- package/dist/es/value/use-scroll.mjs +2 -2
- package/dist/es/value/use-will-change/index.mjs +2 -2
- package/dist/framer-motion.dev.js +238 -370
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +12 -3
- package/dist/projection.dev.js +53 -78
- package/dist/size-rollup-dom-animation-assets.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max-assets.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/dist/size-webpack-m.js +1 -1
- package/dist/three-entry.d.ts +1 -1
- package/package.json +9 -11
|
@@ -150,19 +150,20 @@
|
|
|
150
150
|
return typeof v === "object" && typeof v.start === "function";
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
const
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"whileHover"
|
|
158
|
-
"
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
"whileInView",
|
|
153
|
+
const variantPriorityOrder$1 = [
|
|
154
|
+
"animate" /* AnimationType.Animate */,
|
|
155
|
+
"whileInView" /* AnimationType.InView */,
|
|
156
|
+
"whileFocus" /* AnimationType.Focus */,
|
|
157
|
+
"whileHover" /* AnimationType.Hover */,
|
|
158
|
+
"whileTap" /* AnimationType.Tap */,
|
|
159
|
+
"whileDrag" /* AnimationType.Drag */,
|
|
160
|
+
"exit" /* AnimationType.Exit */,
|
|
162
161
|
];
|
|
162
|
+
const variantProps = ["initial", ...variantPriorityOrder$1];
|
|
163
|
+
|
|
163
164
|
function isControllingVariants(props) {
|
|
164
165
|
return (isAnimationControls(props.animate) ||
|
|
165
|
-
variantProps
|
|
166
|
+
variantProps.some((name) => isVariantLabel(props[name])));
|
|
166
167
|
}
|
|
167
168
|
function isVariantNode(props) {
|
|
168
169
|
return Boolean(isControllingVariants(props) || props.variants);
|
|
@@ -538,12 +539,9 @@
|
|
|
538
539
|
return transformString;
|
|
539
540
|
}
|
|
540
541
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
function isCSSVariable$1(key) {
|
|
545
|
-
return key.startsWith("--");
|
|
546
|
-
}
|
|
542
|
+
const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
|
|
543
|
+
const isCSSVariableName = checkStringStartsWith("--");
|
|
544
|
+
const isCSSVariableToken = checkStringStartsWith("var(--");
|
|
547
545
|
|
|
548
546
|
/**
|
|
549
547
|
* Provided a value and a ValueType, returns the value as that value type.
|
|
@@ -554,7 +552,7 @@
|
|
|
554
552
|
: value;
|
|
555
553
|
};
|
|
556
554
|
|
|
557
|
-
const clamp
|
|
555
|
+
const clamp = (min, max, v) => Math.min(Math.max(v, min), max);
|
|
558
556
|
|
|
559
557
|
const number = {
|
|
560
558
|
test: (v) => typeof v === "number",
|
|
@@ -563,7 +561,7 @@
|
|
|
563
561
|
};
|
|
564
562
|
const alpha = {
|
|
565
563
|
...number,
|
|
566
|
-
transform: (v) => clamp
|
|
564
|
+
transform: (v) => clamp(0, 1, v),
|
|
567
565
|
};
|
|
568
566
|
const scale = {
|
|
569
567
|
...number,
|
|
@@ -580,12 +578,12 @@
|
|
|
580
578
|
const floatRegex = /(-)?([\d]*\.?[\d])+/g;
|
|
581
579
|
const colorRegex = /(#[0-9a-f]{3,8}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi;
|
|
582
580
|
const singleColorRegex = /^(#[0-9a-f]{3,8}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;
|
|
583
|
-
function isString
|
|
581
|
+
function isString(v) {
|
|
584
582
|
return typeof v === "string";
|
|
585
583
|
}
|
|
586
584
|
|
|
587
585
|
const createUnitType = (unit) => ({
|
|
588
|
-
test: (v) => isString
|
|
586
|
+
test: (v) => isString(v) && v.endsWith(unit) && v.split(" ").length === 1,
|
|
589
587
|
parse: parseFloat,
|
|
590
588
|
transform: (v) => `${v}${unit}`,
|
|
591
589
|
});
|
|
@@ -690,7 +688,7 @@
|
|
|
690
688
|
/**
|
|
691
689
|
* If this is a CSS variable we don't do any further processing.
|
|
692
690
|
*/
|
|
693
|
-
if (
|
|
691
|
+
if (isCSSVariableName(key)) {
|
|
694
692
|
vars[key] = value;
|
|
695
693
|
continue;
|
|
696
694
|
}
|
|
@@ -1329,17 +1327,6 @@
|
|
|
1329
1327
|
return addDomEvent(target, eventName, addPointerInfo(handler), options);
|
|
1330
1328
|
}
|
|
1331
1329
|
|
|
1332
|
-
exports.AnimationType = void 0;
|
|
1333
|
-
(function (AnimationType) {
|
|
1334
|
-
AnimationType["Animate"] = "animate";
|
|
1335
|
-
AnimationType["Hover"] = "whileHover";
|
|
1336
|
-
AnimationType["Tap"] = "whileTap";
|
|
1337
|
-
AnimationType["Drag"] = "whileDrag";
|
|
1338
|
-
AnimationType["Focus"] = "whileFocus";
|
|
1339
|
-
AnimationType["InView"] = "whileInView";
|
|
1340
|
-
AnimationType["Exit"] = "exit";
|
|
1341
|
-
})(exports.AnimationType || (exports.AnimationType = {}));
|
|
1342
|
-
|
|
1343
1330
|
/**
|
|
1344
1331
|
* Pipe
|
|
1345
1332
|
* Compose other transformers to run linearily
|
|
@@ -1418,7 +1405,7 @@
|
|
|
1418
1405
|
return;
|
|
1419
1406
|
const props = node.getProps();
|
|
1420
1407
|
if (node.animationState && props.whileHover) {
|
|
1421
|
-
node.animationState.setActive(
|
|
1408
|
+
node.animationState.setActive("whileHover" /* AnimationType.Hover */, isActive);
|
|
1422
1409
|
}
|
|
1423
1410
|
if (props[callbackName]) {
|
|
1424
1411
|
props[callbackName](event, info);
|
|
@@ -1456,13 +1443,13 @@
|
|
|
1456
1443
|
}
|
|
1457
1444
|
if (!isFocusVisible || !this.node.animationState)
|
|
1458
1445
|
return;
|
|
1459
|
-
this.node.animationState.setActive(
|
|
1446
|
+
this.node.animationState.setActive("whileFocus" /* AnimationType.Focus */, true);
|
|
1460
1447
|
this.isActive = true;
|
|
1461
1448
|
}
|
|
1462
1449
|
onBlur() {
|
|
1463
1450
|
if (!this.isActive || !this.node.animationState)
|
|
1464
1451
|
return;
|
|
1465
|
-
this.node.animationState.setActive(
|
|
1452
|
+
this.node.animationState.setActive("whileFocus" /* AnimationType.Focus */, false);
|
|
1466
1453
|
this.isActive = false;
|
|
1467
1454
|
}
|
|
1468
1455
|
mount() {
|
|
@@ -1558,7 +1545,7 @@
|
|
|
1558
1545
|
* Ensure we trigger animations before firing event callback
|
|
1559
1546
|
*/
|
|
1560
1547
|
if (whileTap && this.node.animationState) {
|
|
1561
|
-
this.node.animationState.setActive(
|
|
1548
|
+
this.node.animationState.setActive("whileTap" /* AnimationType.Tap */, true);
|
|
1562
1549
|
}
|
|
1563
1550
|
onTapStart && onTapStart(event, info);
|
|
1564
1551
|
}
|
|
@@ -1567,7 +1554,7 @@
|
|
|
1567
1554
|
this.isPressing = false;
|
|
1568
1555
|
const props = this.node.getProps();
|
|
1569
1556
|
if (props.whileTap && this.node.animationState) {
|
|
1570
|
-
this.node.animationState.setActive(
|
|
1557
|
+
this.node.animationState.setActive("whileTap" /* AnimationType.Tap */, false);
|
|
1571
1558
|
}
|
|
1572
1559
|
return !isDragActive();
|
|
1573
1560
|
}
|
|
@@ -1662,7 +1649,7 @@
|
|
|
1662
1649
|
const { onViewportEnter } = this.node.getProps();
|
|
1663
1650
|
onViewportEnter && onViewportEnter(null);
|
|
1664
1651
|
if (this.node.animationState) {
|
|
1665
|
-
this.node.animationState.setActive(
|
|
1652
|
+
this.node.animationState.setActive("whileInView" /* AnimationType.InView */, true);
|
|
1666
1653
|
}
|
|
1667
1654
|
});
|
|
1668
1655
|
}
|
|
@@ -1699,7 +1686,7 @@
|
|
|
1699
1686
|
this.hasEnteredView = true;
|
|
1700
1687
|
}
|
|
1701
1688
|
if (this.node.animationState) {
|
|
1702
|
-
this.node.animationState.setActive(
|
|
1689
|
+
this.node.animationState.setActive("whileInView" /* AnimationType.InView */, isIntersecting);
|
|
1703
1690
|
}
|
|
1704
1691
|
/**
|
|
1705
1692
|
* Use the latest committed props rather than the ones in scope
|
|
@@ -1987,7 +1974,7 @@
|
|
|
1987
1974
|
@param [number]: Unit per frame
|
|
1988
1975
|
@param [number]: Frame duration in ms
|
|
1989
1976
|
*/
|
|
1990
|
-
function velocityPerSecond
|
|
1977
|
+
function velocityPerSecond(velocity, frameDuration) {
|
|
1991
1978
|
return frameDuration ? velocity * (1000 / frameDuration) : 0;
|
|
1992
1979
|
}
|
|
1993
1980
|
|
|
@@ -2013,7 +2000,7 @@
|
|
|
2013
2000
|
* This will be replaced by the build step with the latest version number.
|
|
2014
2001
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
2015
2002
|
*/
|
|
2016
|
-
this.version = "9.1.
|
|
2003
|
+
this.version = "9.1.2";
|
|
2017
2004
|
/**
|
|
2018
2005
|
* Duration, in milliseconds, since last updating frame.
|
|
2019
2006
|
*
|
|
@@ -2236,7 +2223,7 @@
|
|
|
2236
2223
|
// This could be isFloat(this.prev) && isFloat(this.current), but that would be wasteful
|
|
2237
2224
|
return this.canTrackVelocity
|
|
2238
2225
|
? // These casts could be avoided if parseFloat would be typed better
|
|
2239
|
-
velocityPerSecond
|
|
2226
|
+
velocityPerSecond(parseFloat(this.current) -
|
|
2240
2227
|
parseFloat(this.prev), this.timeDelta)
|
|
2241
2228
|
: 0;
|
|
2242
2229
|
}
|
|
@@ -2318,11 +2305,11 @@
|
|
|
2318
2305
|
* but false if a number or multiple colors
|
|
2319
2306
|
*/
|
|
2320
2307
|
const isColorString = (type, testProp) => (v) => {
|
|
2321
|
-
return Boolean((isString
|
|
2308
|
+
return Boolean((isString(v) && singleColorRegex.test(v) && v.startsWith(type)) ||
|
|
2322
2309
|
(testProp && Object.prototype.hasOwnProperty.call(v, testProp)));
|
|
2323
2310
|
};
|
|
2324
2311
|
const splitColor = (aName, bName, cName) => (v) => {
|
|
2325
|
-
if (!isString
|
|
2312
|
+
if (!isString(v))
|
|
2326
2313
|
return v;
|
|
2327
2314
|
const [a, b, c, alpha] = v.match(floatRegex);
|
|
2328
2315
|
return {
|
|
@@ -2333,7 +2320,7 @@
|
|
|
2333
2320
|
};
|
|
2334
2321
|
};
|
|
2335
2322
|
|
|
2336
|
-
const clampRgbUnit = (v) => clamp
|
|
2323
|
+
const clampRgbUnit = (v) => clamp(0, 255, v);
|
|
2337
2324
|
const rgbUnit = {
|
|
2338
2325
|
...number,
|
|
2339
2326
|
transform: (v) => Math.round(clampRgbUnit(v)),
|
|
@@ -2418,7 +2405,7 @@
|
|
|
2418
2405
|
}
|
|
2419
2406
|
},
|
|
2420
2407
|
transform: (v) => {
|
|
2421
|
-
return isString
|
|
2408
|
+
return isString(v)
|
|
2422
2409
|
? v
|
|
2423
2410
|
: v.hasOwnProperty("red")
|
|
2424
2411
|
? rgba.transform(v)
|
|
@@ -2431,7 +2418,7 @@
|
|
|
2431
2418
|
function test(v) {
|
|
2432
2419
|
var _a, _b;
|
|
2433
2420
|
return (isNaN(v) &&
|
|
2434
|
-
isString
|
|
2421
|
+
isString(v) &&
|
|
2435
2422
|
(((_a = v.match(floatRegex)) === null || _a === void 0 ? void 0 : _a.length) || 0) +
|
|
2436
2423
|
(((_b = v.match(colorRegex)) === null || _b === void 0 ? void 0 : _b.length) || 0) >
|
|
2437
2424
|
0);
|
|
@@ -2716,19 +2703,19 @@
|
|
|
2716
2703
|
const optimizedAppearDataId = "framerAppearId";
|
|
2717
2704
|
const optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
|
|
2718
2705
|
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
{
|
|
2722
|
-
warning =
|
|
2723
|
-
if (!check && typeof console !==
|
|
2724
|
-
console.warn(message);
|
|
2725
|
-
}
|
|
2726
|
-
};
|
|
2727
|
-
invariant =
|
|
2728
|
-
if (!check) {
|
|
2729
|
-
throw new Error(message);
|
|
2730
|
-
}
|
|
2731
|
-
};
|
|
2706
|
+
exports.warning = noop;
|
|
2707
|
+
exports.invariant = noop;
|
|
2708
|
+
{
|
|
2709
|
+
exports.warning = (check, message) => {
|
|
2710
|
+
if (!check && typeof console !== "undefined") {
|
|
2711
|
+
console.warn(message);
|
|
2712
|
+
}
|
|
2713
|
+
};
|
|
2714
|
+
exports.invariant = (check, message) => {
|
|
2715
|
+
if (!check) {
|
|
2716
|
+
throw new Error(message);
|
|
2717
|
+
}
|
|
2718
|
+
};
|
|
2732
2719
|
}
|
|
2733
2720
|
|
|
2734
2721
|
/**
|
|
@@ -2776,7 +2763,7 @@
|
|
|
2776
2763
|
@param [number]: The progress between lower and upper limits expressed 0-1
|
|
2777
2764
|
@return [number]: Value as calculated from progress within range (not limited within range)
|
|
2778
2765
|
*/
|
|
2779
|
-
const mix
|
|
2766
|
+
const mix = (from, to, progress) => -progress * from + progress * to + from;
|
|
2780
2767
|
|
|
2781
2768
|
// Adapted from https://gist.github.com/mjackson/5311256
|
|
2782
2769
|
function hueToRgb(p, q, t) {
|
|
@@ -2830,7 +2817,7 @@
|
|
|
2830
2817
|
const getColorType = (v) => colorTypes.find((type) => type.test(v));
|
|
2831
2818
|
function asRGBA(color) {
|
|
2832
2819
|
const type = getColorType(color);
|
|
2833
|
-
invariant(Boolean(type), `'${color}' is not an animatable color. Use the equivalent color code instead.`);
|
|
2820
|
+
exports.invariant(Boolean(type), `'${color}' is not an animatable color. Use the equivalent color code instead.`);
|
|
2834
2821
|
let model = type.parse(color);
|
|
2835
2822
|
if (type === hsla) {
|
|
2836
2823
|
// TODO Remove this cast - needed since Framer Motion's stricter typing
|
|
@@ -2846,14 +2833,14 @@
|
|
|
2846
2833
|
blended.red = mixLinearColor(fromRGBA.red, toRGBA.red, v);
|
|
2847
2834
|
blended.green = mixLinearColor(fromRGBA.green, toRGBA.green, v);
|
|
2848
2835
|
blended.blue = mixLinearColor(fromRGBA.blue, toRGBA.blue, v);
|
|
2849
|
-
blended.alpha = mix
|
|
2836
|
+
blended.alpha = mix(fromRGBA.alpha, toRGBA.alpha, v);
|
|
2850
2837
|
return rgba.transform(blended);
|
|
2851
2838
|
};
|
|
2852
2839
|
};
|
|
2853
2840
|
|
|
2854
2841
|
function getMixer$1(origin, target) {
|
|
2855
2842
|
if (typeof origin === "number") {
|
|
2856
|
-
return (v) => mix
|
|
2843
|
+
return (v) => mix(origin, target, v);
|
|
2857
2844
|
}
|
|
2858
2845
|
else if (color.test(origin)) {
|
|
2859
2846
|
return mixColor(origin, target);
|
|
@@ -2898,7 +2885,7 @@
|
|
|
2898
2885
|
return pipe(mixArray(originStats.values, targetStats.values), template);
|
|
2899
2886
|
}
|
|
2900
2887
|
else {
|
|
2901
|
-
warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
|
|
2888
|
+
exports.warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
|
|
2902
2889
|
return (p) => `${p > 0 ? target : origin}`;
|
|
2903
2890
|
}
|
|
2904
2891
|
};
|
|
@@ -2915,12 +2902,12 @@
|
|
|
2915
2902
|
@param [number]: Value to find progress within given range
|
|
2916
2903
|
@return [number]: Progress of value within range as expressed 0-1
|
|
2917
2904
|
*/
|
|
2918
|
-
const progress
|
|
2905
|
+
const progress = (from, to, value) => {
|
|
2919
2906
|
const toFromDifference = to - from;
|
|
2920
2907
|
return toFromDifference === 0 ? 1 : (value - from) / toFromDifference;
|
|
2921
2908
|
};
|
|
2922
2909
|
|
|
2923
|
-
const mixNumber = (from, to) => (p) => mix
|
|
2910
|
+
const mixNumber = (from, to) => (p) => mix(from, to, p);
|
|
2924
2911
|
function detectMixerFactory(v) {
|
|
2925
2912
|
if (typeof v === "number") {
|
|
2926
2913
|
return mixNumber;
|
|
@@ -2974,10 +2961,10 @@
|
|
|
2974
2961
|
*
|
|
2975
2962
|
* @public
|
|
2976
2963
|
*/
|
|
2977
|
-
function interpolate
|
|
2964
|
+
function interpolate(input, output, { clamp: isClamp = true, ease, mixer } = {}) {
|
|
2978
2965
|
const inputLength = input.length;
|
|
2979
|
-
invariant(inputLength === output.length, "Both input and output ranges must be the same length");
|
|
2980
|
-
invariant(!ease || !Array.isArray(ease) || ease.length === inputLength - 1, "Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values.");
|
|
2966
|
+
exports.invariant(inputLength === output.length, "Both input and output ranges must be the same length");
|
|
2967
|
+
exports.invariant(!ease || !Array.isArray(ease) || ease.length === inputLength - 1, "Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values.");
|
|
2981
2968
|
// If input runs highest -> lowest, reverse both arrays
|
|
2982
2969
|
if (input[0] > input[inputLength - 1]) {
|
|
2983
2970
|
input = [...input].reverse();
|
|
@@ -2993,14 +2980,32 @@
|
|
|
2993
2980
|
break;
|
|
2994
2981
|
}
|
|
2995
2982
|
}
|
|
2996
|
-
const progressInRange = progress
|
|
2983
|
+
const progressInRange = progress(input[i], input[i + 1], v);
|
|
2997
2984
|
return mixers[i](progressInRange);
|
|
2998
2985
|
};
|
|
2999
2986
|
return isClamp
|
|
3000
|
-
? (v) => interpolator(clamp
|
|
2987
|
+
? (v) => interpolator(clamp(input[0], input[inputLength - 1], v))
|
|
3001
2988
|
: interpolator;
|
|
3002
2989
|
}
|
|
3003
2990
|
|
|
2991
|
+
function fillOffset(offset, remaining) {
|
|
2992
|
+
const min = offset[offset.length - 1];
|
|
2993
|
+
for (let i = 1; i <= remaining; i++) {
|
|
2994
|
+
const offsetProgress = progress(0, remaining, i);
|
|
2995
|
+
offset.push(mix(min, 1, offsetProgress));
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
function defaultOffset$1(arr) {
|
|
3000
|
+
const offset = [0];
|
|
3001
|
+
fillOffset(offset, arr.length - 1);
|
|
3002
|
+
return offset;
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
function convertOffsetToTimes(offset, duration) {
|
|
3006
|
+
return offset.map((o) => o * duration);
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3004
3009
|
/*
|
|
3005
3010
|
Bezier function generator
|
|
3006
3011
|
This has been modified from Gaëtan Renaudeau's BezierEasing
|
|
@@ -3075,13 +3080,13 @@
|
|
|
3075
3080
|
const easingDefinitionToFunction = (definition) => {
|
|
3076
3081
|
if (Array.isArray(definition)) {
|
|
3077
3082
|
// If cubic bezier definition, create bezier curve
|
|
3078
|
-
invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`);
|
|
3083
|
+
exports.invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`);
|
|
3079
3084
|
const [x1, y1, x2, y2] = definition;
|
|
3080
3085
|
return cubicBezier(x1, y1, x2, y2);
|
|
3081
3086
|
}
|
|
3082
3087
|
else if (typeof definition === "string") {
|
|
3083
3088
|
// Else lookup from table
|
|
3084
|
-
invariant(easingLookup[definition] !== undefined, `Invalid easing type '${definition}'`);
|
|
3089
|
+
exports.invariant(easingLookup[definition] !== undefined, `Invalid easing type '${definition}'`);
|
|
3085
3090
|
return easingLookup[definition];
|
|
3086
3091
|
}
|
|
3087
3092
|
return definition;
|
|
@@ -3093,13 +3098,6 @@
|
|
|
3093
3098
|
function defaultEasing(values, easing) {
|
|
3094
3099
|
return values.map(() => easing || easeInOut).splice(0, values.length - 1);
|
|
3095
3100
|
}
|
|
3096
|
-
function defaultOffset$2(values) {
|
|
3097
|
-
const numValues = values.length;
|
|
3098
|
-
return values.map((_value, i) => i !== 0 ? i / (numValues - 1) : 0);
|
|
3099
|
-
}
|
|
3100
|
-
function convertOffsetToTimes(offset, duration) {
|
|
3101
|
-
return offset.map((o) => o * duration);
|
|
3102
|
-
}
|
|
3103
3101
|
function keyframes({ keyframes: keyframeValues, ease = easeInOut, times, duration = 300, }) {
|
|
3104
3102
|
keyframeValues = [...keyframeValues];
|
|
3105
3103
|
/**
|
|
@@ -3125,9 +3123,9 @@
|
|
|
3125
3123
|
// TODO Maybe we should warn here if there's a length mismatch
|
|
3126
3124
|
times && times.length === keyframeValues.length
|
|
3127
3125
|
? times
|
|
3128
|
-
: defaultOffset$
|
|
3126
|
+
: defaultOffset$1(keyframeValues), duration);
|
|
3129
3127
|
function createInterpolator() {
|
|
3130
|
-
return interpolate
|
|
3128
|
+
return interpolate(absoluteTimes, keyframeValues, {
|
|
3131
3129
|
ease: Array.isArray(easingFunctions)
|
|
3132
3130
|
? easingFunctions
|
|
3133
3131
|
: defaultEasing(keyframeValues, easingFunctions),
|
|
@@ -3155,13 +3153,13 @@
|
|
|
3155
3153
|
function findSpring({ duration = 800, bounce = 0.25, velocity = 0, mass = 1, }) {
|
|
3156
3154
|
let envelope;
|
|
3157
3155
|
let derivative;
|
|
3158
|
-
warning(duration <= maxDuration * 1000, "Spring duration must be 10 seconds or less");
|
|
3156
|
+
exports.warning(duration <= maxDuration * 1000, "Spring duration must be 10 seconds or less");
|
|
3159
3157
|
let dampingRatio = 1 - bounce;
|
|
3160
3158
|
/**
|
|
3161
3159
|
* Restrict dampingRatio and duration to within acceptable ranges.
|
|
3162
3160
|
*/
|
|
3163
|
-
dampingRatio = clamp
|
|
3164
|
-
duration = clamp
|
|
3161
|
+
dampingRatio = clamp(minDamping, maxDamping, dampingRatio);
|
|
3162
|
+
duration = clamp(minDuration, maxDuration, duration / 1000);
|
|
3165
3163
|
if (dampingRatio < 1) {
|
|
3166
3164
|
/**
|
|
3167
3165
|
* Underdamped spring
|
|
@@ -3343,7 +3341,7 @@
|
|
|
3343
3341
|
*/
|
|
3344
3342
|
if (dampingRatio < 1) {
|
|
3345
3343
|
const prevT = Math.max(0, t - velocitySampleDuration);
|
|
3346
|
-
currentVelocity = velocityPerSecond
|
|
3344
|
+
currentVelocity = velocityPerSecond(current - resolveSpring(prevT), t - prevT);
|
|
3347
3345
|
}
|
|
3348
3346
|
else {
|
|
3349
3347
|
currentVelocity = 0;
|
|
@@ -3445,7 +3443,7 @@
|
|
|
3445
3443
|
*/
|
|
3446
3444
|
const { needsInterpolation } = animator;
|
|
3447
3445
|
if (needsInterpolation && needsInterpolation(origin, target)) {
|
|
3448
|
-
interpolateFromNumber = interpolate
|
|
3446
|
+
interpolateFromNumber = interpolate([0, 100], [origin, target], {
|
|
3449
3447
|
clamp: false,
|
|
3450
3448
|
});
|
|
3451
3449
|
keyframes$1 = [0, 100];
|
|
@@ -3805,7 +3803,7 @@
|
|
|
3805
3803
|
const checkBoundary = (v) => {
|
|
3806
3804
|
prev = current;
|
|
3807
3805
|
current = v;
|
|
3808
|
-
velocity = velocityPerSecond
|
|
3806
|
+
velocity = velocityPerSecond(v - prev, frameData.delta);
|
|
3809
3807
|
if ((heading === 1 && v > boundary) ||
|
|
3810
3808
|
(heading === -1 && v < boundary)) {
|
|
3811
3809
|
startSpring({ keyframes: [v, boundary], velocity });
|
|
@@ -3975,7 +3973,7 @@
|
|
|
3975
3973
|
const targetKeyframe = keyframes[keyframes.length - 1];
|
|
3976
3974
|
const isOriginAnimatable = isAnimatable(valueName, originKeyframe);
|
|
3977
3975
|
const isTargetAnimatable = isAnimatable(valueName, targetKeyframe);
|
|
3978
|
-
warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${valueName} from "${originKeyframe}" to "${targetKeyframe}". ${originKeyframe} is not an animatable value - to enable this animation set ${originKeyframe} to a value animatable to ${targetKeyframe} via the \`style\` property.`);
|
|
3976
|
+
exports.warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${valueName} from "${originKeyframe}" to "${targetKeyframe}". ${originKeyframe} is not an animatable value - to enable this animation set ${originKeyframe} to a value animatable to ${targetKeyframe} via the \`style\` property.`);
|
|
3979
3977
|
let options = {
|
|
3980
3978
|
keyframes,
|
|
3981
3979
|
velocity: value.getVelocity(),
|
|
@@ -4182,13 +4180,13 @@
|
|
|
4182
4180
|
}
|
|
4183
4181
|
|
|
4184
4182
|
const variantPriorityOrder = [
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4183
|
+
"animate" /* AnimationType.Animate */,
|
|
4184
|
+
"whileInView" /* AnimationType.InView */,
|
|
4185
|
+
"whileFocus" /* AnimationType.Focus */,
|
|
4186
|
+
"whileHover" /* AnimationType.Hover */,
|
|
4187
|
+
"whileTap" /* AnimationType.Tap */,
|
|
4188
|
+
"whileDrag" /* AnimationType.Drag */,
|
|
4189
|
+
"exit" /* AnimationType.Exit */,
|
|
4192
4190
|
];
|
|
4193
4191
|
const reversePriorityOrder = [...variantPriorityOrder].reverse();
|
|
4194
4192
|
const numAnimationTypes = variantPriorityOrder.length;
|
|
@@ -4451,16 +4449,12 @@
|
|
|
4451
4449
|
* Change whether a certain animation type is active.
|
|
4452
4450
|
*/
|
|
4453
4451
|
function setActive(type, isActive, options) {
|
|
4452
|
+
var _a;
|
|
4454
4453
|
// If the active state hasn't changed, we can safely do nothing here
|
|
4455
4454
|
if (state[type].isActive === isActive)
|
|
4456
4455
|
return Promise.resolve();
|
|
4457
4456
|
// Propagate active change to children
|
|
4458
|
-
|
|
4459
|
-
visualElement.variantChildren.forEach((child) => {
|
|
4460
|
-
child.animationState &&
|
|
4461
|
-
child.animationState.setActive(type, isActive);
|
|
4462
|
-
});
|
|
4463
|
-
}
|
|
4457
|
+
(_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach((child) => { var _a; return (_a = child.animationState) === null || _a === void 0 ? void 0 : _a.setActive(type, isActive); });
|
|
4464
4458
|
state[type].isActive = isActive;
|
|
4465
4459
|
const animations = animateChanges(options, type);
|
|
4466
4460
|
for (const key in state) {
|
|
@@ -4494,13 +4488,13 @@
|
|
|
4494
4488
|
}
|
|
4495
4489
|
function createState() {
|
|
4496
4490
|
return {
|
|
4497
|
-
[
|
|
4498
|
-
[
|
|
4499
|
-
[
|
|
4500
|
-
[
|
|
4501
|
-
[
|
|
4502
|
-
[
|
|
4503
|
-
[
|
|
4491
|
+
["animate" /* AnimationType.Animate */]: createTypeState(true),
|
|
4492
|
+
["whileInView" /* AnimationType.InView */]: createTypeState(),
|
|
4493
|
+
["whileHover" /* AnimationType.Hover */]: createTypeState(),
|
|
4494
|
+
["whileTap" /* AnimationType.Tap */]: createTypeState(),
|
|
4495
|
+
["whileDrag" /* AnimationType.Drag */]: createTypeState(),
|
|
4496
|
+
["whileFocus" /* AnimationType.Focus */]: createTypeState(),
|
|
4497
|
+
["exit" /* AnimationType.Exit */]: createTypeState(),
|
|
4504
4498
|
};
|
|
4505
4499
|
}
|
|
4506
4500
|
|
|
@@ -4551,7 +4545,7 @@
|
|
|
4551
4545
|
if (!this.node.animationState || isPresent === prevIsPresent) {
|
|
4552
4546
|
return;
|
|
4553
4547
|
}
|
|
4554
|
-
const exitAnimation = this.node.animationState.setActive(
|
|
4548
|
+
const exitAnimation = this.node.animationState.setActive("exit" /* AnimationType.Exit */, !isPresent, { custom: custom !== null && custom !== void 0 ? custom : this.node.getProps().custom });
|
|
4555
4549
|
if (onExitComplete && !isPresent) {
|
|
4556
4550
|
exitAnimation.then(() => onExitComplete(this.id));
|
|
4557
4551
|
}
|
|
@@ -4729,12 +4723,12 @@
|
|
|
4729
4723
|
}
|
|
4730
4724
|
function calcAxisDelta(delta, source, target, origin = 0.5) {
|
|
4731
4725
|
delta.origin = origin;
|
|
4732
|
-
delta.originPoint = mix
|
|
4726
|
+
delta.originPoint = mix(source.min, source.max, delta.origin);
|
|
4733
4727
|
delta.scale = calcLength(target) / calcLength(source);
|
|
4734
4728
|
if (isNear(delta.scale, 1, 0.0001) || isNaN(delta.scale))
|
|
4735
4729
|
delta.scale = 1;
|
|
4736
4730
|
delta.translate =
|
|
4737
|
-
mix
|
|
4731
|
+
mix(target.min, target.max, delta.origin) - delta.originPoint;
|
|
4738
4732
|
if (isNear(delta.translate) || isNaN(delta.translate))
|
|
4739
4733
|
delta.translate = 0;
|
|
4740
4734
|
}
|
|
@@ -4767,11 +4761,11 @@
|
|
|
4767
4761
|
function applyConstraints(point, { min, max }, elastic) {
|
|
4768
4762
|
if (min !== undefined && point < min) {
|
|
4769
4763
|
// If we have a min point defined, and this is outside of that, constrain
|
|
4770
|
-
point = elastic ? mix
|
|
4764
|
+
point = elastic ? mix(min, point, elastic.min) : Math.max(point, min);
|
|
4771
4765
|
}
|
|
4772
4766
|
else if (max !== undefined && point > max) {
|
|
4773
4767
|
// If we have a max point defined, and this is outside of that, constrain
|
|
4774
|
-
point = elastic ? mix
|
|
4768
|
+
point = elastic ? mix(max, point, elastic.max) : Math.min(point, max);
|
|
4775
4769
|
}
|
|
4776
4770
|
return point;
|
|
4777
4771
|
}
|
|
@@ -4830,12 +4824,12 @@
|
|
|
4830
4824
|
const sourceLength = calcLength(source);
|
|
4831
4825
|
const targetLength = calcLength(target);
|
|
4832
4826
|
if (targetLength > sourceLength) {
|
|
4833
|
-
origin = progress
|
|
4827
|
+
origin = progress(target.min, target.max - sourceLength, source.min);
|
|
4834
4828
|
}
|
|
4835
4829
|
else if (sourceLength > targetLength) {
|
|
4836
|
-
origin = progress
|
|
4830
|
+
origin = progress(source.min, source.max - targetLength, target.min);
|
|
4837
4831
|
}
|
|
4838
|
-
return clamp
|
|
4832
|
+
return clamp(0, 1, origin);
|
|
4839
4833
|
}
|
|
4840
4834
|
/**
|
|
4841
4835
|
* Rebase the calculated viewport constraints relative to the layout.min point.
|
|
@@ -5054,7 +5048,7 @@
|
|
|
5054
5048
|
*/
|
|
5055
5049
|
function transformAxis(axis, transforms, [key, scaleKey, originKey]) {
|
|
5056
5050
|
const axisOrigin = transforms[originKey] !== undefined ? transforms[originKey] : 0.5;
|
|
5057
|
-
const originPoint = mix
|
|
5051
|
+
const originPoint = mix(axis.min, axis.max, axisOrigin);
|
|
5058
5052
|
// Apply the axis delta to the final axis
|
|
5059
5053
|
applyAxisDelta(axis, transforms[key], transforms[scaleKey], originPoint, transforms.scale);
|
|
5060
5054
|
}
|
|
@@ -5165,7 +5159,7 @@
|
|
|
5165
5159
|
// Fire onDragStart event
|
|
5166
5160
|
onDragStart && onDragStart(event, info);
|
|
5167
5161
|
const { animationState } = this.visualElement;
|
|
5168
|
-
animationState && animationState.setActive(
|
|
5162
|
+
animationState && animationState.setActive("whileDrag" /* AnimationType.Drag */, true);
|
|
5169
5163
|
};
|
|
5170
5164
|
const onMove = (event, info) => {
|
|
5171
5165
|
// latestPointerEvent = event
|
|
@@ -5230,7 +5224,7 @@
|
|
|
5230
5224
|
this.openGlobalLock();
|
|
5231
5225
|
this.openGlobalLock = null;
|
|
5232
5226
|
}
|
|
5233
|
-
animationState && animationState.setActive(
|
|
5227
|
+
animationState && animationState.setActive("whileDrag" /* AnimationType.Drag */, false);
|
|
5234
5228
|
}
|
|
5235
5229
|
updateAxis(axis, _point, offset) {
|
|
5236
5230
|
const { drag } = this.getProps();
|
|
@@ -5283,7 +5277,7 @@
|
|
|
5283
5277
|
if (!constraints || !isRefObject(constraints))
|
|
5284
5278
|
return false;
|
|
5285
5279
|
const constraintsElement = constraints.current;
|
|
5286
|
-
invariant(constraintsElement !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");
|
|
5280
|
+
exports.invariant(constraintsElement !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");
|
|
5287
5281
|
const { projection } = this.visualElement;
|
|
5288
5282
|
// TODO
|
|
5289
5283
|
if (!projection || !projection.layout)
|
|
@@ -5371,7 +5365,7 @@
|
|
|
5371
5365
|
const axisValue = this.getAxisMotionValue(axis);
|
|
5372
5366
|
if (projection && projection.layout) {
|
|
5373
5367
|
const { min, max } = projection.layout.layoutBox[axis];
|
|
5374
|
-
axisValue.set(point[axis] - mix
|
|
5368
|
+
axisValue.set(point[axis] - mix(min, max, 0.5));
|
|
5375
5369
|
}
|
|
5376
5370
|
});
|
|
5377
5371
|
}
|
|
@@ -5426,7 +5420,7 @@
|
|
|
5426
5420
|
*/
|
|
5427
5421
|
const axisValue = this.getAxisMotionValue(axis);
|
|
5428
5422
|
const { min, max } = this.constraints[axis];
|
|
5429
|
-
axisValue.set(mix
|
|
5423
|
+
axisValue.set(mix(min, max, boxProgress[axis]));
|
|
5430
5424
|
});
|
|
5431
5425
|
}
|
|
5432
5426
|
addListeners() {
|
|
@@ -5614,13 +5608,13 @@
|
|
|
5614
5608
|
const isPx = (value) => typeof value === "number" || px.test(value);
|
|
5615
5609
|
function mixValues(target, follow, lead, progress, shouldCrossfadeOpacity, isOnlyMember) {
|
|
5616
5610
|
if (shouldCrossfadeOpacity) {
|
|
5617
|
-
target.opacity = mix
|
|
5611
|
+
target.opacity = mix(0,
|
|
5618
5612
|
// TODO Reinstate this if only child
|
|
5619
5613
|
lead.opacity !== undefined ? lead.opacity : 1, easeCrossfadeIn(progress));
|
|
5620
|
-
target.opacityExit = mix
|
|
5614
|
+
target.opacityExit = mix(follow.opacity !== undefined ? follow.opacity : 1, 0, easeCrossfadeOut(progress));
|
|
5621
5615
|
}
|
|
5622
5616
|
else if (isOnlyMember) {
|
|
5623
|
-
target.opacity = mix
|
|
5617
|
+
target.opacity = mix(follow.opacity !== undefined ? follow.opacity : 1, lead.opacity !== undefined ? lead.opacity : 1, progress);
|
|
5624
5618
|
}
|
|
5625
5619
|
/**
|
|
5626
5620
|
* Mix border radius
|
|
@@ -5637,7 +5631,7 @@
|
|
|
5637
5631
|
leadRadius === 0 ||
|
|
5638
5632
|
isPx(followRadius) === isPx(leadRadius);
|
|
5639
5633
|
if (canMix) {
|
|
5640
|
-
target[borderLabel] = Math.max(mix
|
|
5634
|
+
target[borderLabel] = Math.max(mix(asNumber(followRadius), asNumber(leadRadius), progress), 0);
|
|
5641
5635
|
if (percent.test(leadRadius) || percent.test(followRadius)) {
|
|
5642
5636
|
target[borderLabel] += "%";
|
|
5643
5637
|
}
|
|
@@ -5650,7 +5644,7 @@
|
|
|
5650
5644
|
* Mix rotation
|
|
5651
5645
|
*/
|
|
5652
5646
|
if (follow.rotate || lead.rotate) {
|
|
5653
|
-
target.rotate = mix
|
|
5647
|
+
target.rotate = mix(follow.rotate || 0, lead.rotate || 0, progress);
|
|
5654
5648
|
}
|
|
5655
5649
|
}
|
|
5656
5650
|
function getRadius(values, radiusName) {
|
|
@@ -5690,7 +5684,7 @@
|
|
|
5690
5684
|
return 0;
|
|
5691
5685
|
if (p > max)
|
|
5692
5686
|
return 1;
|
|
5693
|
-
return easing(progress
|
|
5687
|
+
return easing(progress(min, max, p));
|
|
5694
5688
|
};
|
|
5695
5689
|
}
|
|
5696
5690
|
|
|
@@ -5730,12 +5724,12 @@
|
|
|
5730
5724
|
function removeAxisDelta(axis, translate = 0, scale = 1, origin = 0.5, boxScale, originAxis = axis, sourceAxis = axis) {
|
|
5731
5725
|
if (percent.test(translate)) {
|
|
5732
5726
|
translate = parseFloat(translate);
|
|
5733
|
-
const relativeProgress = mix
|
|
5727
|
+
const relativeProgress = mix(sourceAxis.min, sourceAxis.max, translate / 100);
|
|
5734
5728
|
translate = relativeProgress - sourceAxis.min;
|
|
5735
5729
|
}
|
|
5736
5730
|
if (typeof translate !== "number")
|
|
5737
5731
|
return;
|
|
5738
|
-
let originPoint = mix
|
|
5732
|
+
let originPoint = mix(originAxis.min, originAxis.max, origin);
|
|
5739
5733
|
if (axis === originAxis)
|
|
5740
5734
|
originPoint -= translate;
|
|
5741
5735
|
axis.min = removePointDelta(axis.min, translate, scale, originPoint, boxScale);
|
|
@@ -7224,14 +7218,14 @@
|
|
|
7224
7218
|
stack.removeLeadSnapshot();
|
|
7225
7219
|
}
|
|
7226
7220
|
function mixAxisDelta(output, delta, p) {
|
|
7227
|
-
output.translate = mix
|
|
7228
|
-
output.scale = mix
|
|
7221
|
+
output.translate = mix(delta.translate, 0, p);
|
|
7222
|
+
output.scale = mix(delta.scale, 1, p);
|
|
7229
7223
|
output.origin = delta.origin;
|
|
7230
7224
|
output.originPoint = delta.originPoint;
|
|
7231
7225
|
}
|
|
7232
7226
|
function mixAxis(output, from, to, p) {
|
|
7233
|
-
output.min = mix
|
|
7234
|
-
output.max = mix
|
|
7227
|
+
output.min = mix(from.min, to.min, p);
|
|
7228
|
+
output.max = mix(from.max, to.max, p);
|
|
7235
7229
|
}
|
|
7236
7230
|
function mixBox(output, from, to, p) {
|
|
7237
7231
|
mixAxis(output.x, from.x, to.x, p);
|
|
@@ -7368,9 +7362,6 @@
|
|
|
7368
7362
|
},
|
|
7369
7363
|
};
|
|
7370
7364
|
|
|
7371
|
-
function isCSSVariable(value) {
|
|
7372
|
-
return typeof value === "string" && value.startsWith("var(--");
|
|
7373
|
-
}
|
|
7374
7365
|
/**
|
|
7375
7366
|
* Parse Framer's special CSS variable format into a CSS token and a fallback.
|
|
7376
7367
|
*
|
|
@@ -7390,7 +7381,7 @@
|
|
|
7390
7381
|
}
|
|
7391
7382
|
const maxDepth = 4;
|
|
7392
7383
|
function getVariableValue(current, element, depth = 1) {
|
|
7393
|
-
invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`);
|
|
7384
|
+
exports.invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`);
|
|
7394
7385
|
const [token, fallback] = parseCSSVariable(current);
|
|
7395
7386
|
// No CSS variable detected
|
|
7396
7387
|
if (!token)
|
|
@@ -7400,7 +7391,7 @@
|
|
|
7400
7391
|
if (resolved) {
|
|
7401
7392
|
return resolved.trim();
|
|
7402
7393
|
}
|
|
7403
|
-
else if (
|
|
7394
|
+
else if (isCSSVariableToken(fallback)) {
|
|
7404
7395
|
// The fallback might itself be a CSS variable, in which case we attempt to resolve it too.
|
|
7405
7396
|
return getVariableValue(fallback, element, depth + 1);
|
|
7406
7397
|
}
|
|
@@ -7425,7 +7416,7 @@
|
|
|
7425
7416
|
// Go through existing `MotionValue`s and ensure any existing CSS variables are resolved
|
|
7426
7417
|
visualElement.values.forEach((value) => {
|
|
7427
7418
|
const current = value.get();
|
|
7428
|
-
if (!
|
|
7419
|
+
if (!isCSSVariableToken(current))
|
|
7429
7420
|
return;
|
|
7430
7421
|
const resolved = getVariableValue(current, element);
|
|
7431
7422
|
if (resolved)
|
|
@@ -7435,7 +7426,7 @@
|
|
|
7435
7426
|
// we only read single-var properties like `var(--foo)`, not `calc(var(--foo) + 20px)`
|
|
7436
7427
|
for (const key in target) {
|
|
7437
7428
|
const current = target[key];
|
|
7438
|
-
if (!
|
|
7429
|
+
if (!isCSSVariableToken(current))
|
|
7439
7430
|
continue;
|
|
7440
7431
|
const resolved = getVariableValue(current, element);
|
|
7441
7432
|
if (!resolved)
|
|
@@ -7484,7 +7475,7 @@
|
|
|
7484
7475
|
* We could potentially improve the outcome of this by incorporating the ratio between
|
|
7485
7476
|
* the two scales.
|
|
7486
7477
|
*/
|
|
7487
|
-
const averageScale = mix
|
|
7478
|
+
const averageScale = mix(xScale, yScale, 0.5);
|
|
7488
7479
|
// Blur
|
|
7489
7480
|
if (typeof shadow[2 + offset] === "number")
|
|
7490
7481
|
shadow[2 + offset] /= averageScale;
|
|
@@ -7519,15 +7510,6 @@
|
|
|
7519
7510
|
return Object.keys(target).some(isPositionalKey);
|
|
7520
7511
|
};
|
|
7521
7512
|
const isNumOrPxType = (v) => v === number || v === px;
|
|
7522
|
-
var BoundingBoxDimension;
|
|
7523
|
-
(function (BoundingBoxDimension) {
|
|
7524
|
-
BoundingBoxDimension["width"] = "width";
|
|
7525
|
-
BoundingBoxDimension["height"] = "height";
|
|
7526
|
-
BoundingBoxDimension["left"] = "left";
|
|
7527
|
-
BoundingBoxDimension["right"] = "right";
|
|
7528
|
-
BoundingBoxDimension["top"] = "top";
|
|
7529
|
-
BoundingBoxDimension["bottom"] = "bottom";
|
|
7530
|
-
})(BoundingBoxDimension || (BoundingBoxDimension = {}));
|
|
7531
7513
|
const getPosFromMatrix = (matrix, pos) => parseFloat(matrix.split(", ")[pos]);
|
|
7532
7514
|
const getTranslateFromMatrix = (pos2, pos3) => (_bbox, { transform }) => {
|
|
7533
7515
|
if (transform === "none" || !transform)
|
|
@@ -7632,11 +7614,11 @@
|
|
|
7632
7614
|
for (let i = fromIndex; i < numKeyframes; i++) {
|
|
7633
7615
|
if (!toType) {
|
|
7634
7616
|
toType = findDimensionValueType(to[i]);
|
|
7635
|
-
invariant(toType === fromType ||
|
|
7617
|
+
exports.invariant(toType === fromType ||
|
|
7636
7618
|
(isNumOrPxType(fromType) && isNumOrPxType(toType)), "Keyframes must be of the same dimension as the current value");
|
|
7637
7619
|
}
|
|
7638
7620
|
else {
|
|
7639
|
-
invariant(findDimensionValueType(to[i]) === toType, "All keyframes must be of the same type");
|
|
7621
|
+
exports.invariant(findDimensionValueType(to[i]) === toType, "All keyframes must be of the same type");
|
|
7640
7622
|
}
|
|
7641
7623
|
}
|
|
7642
7624
|
}
|
|
@@ -7782,7 +7764,7 @@
|
|
|
7782
7764
|
* and warn against mismatches.
|
|
7783
7765
|
*/
|
|
7784
7766
|
{
|
|
7785
|
-
warnOnce(nextValue.version === "9.1.
|
|
7767
|
+
warnOnce(nextValue.version === "9.1.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.1.2 may not work as expected.`);
|
|
7786
7768
|
}
|
|
7787
7769
|
}
|
|
7788
7770
|
else if (isMotionValue(prevValue)) {
|
|
@@ -7831,6 +7813,7 @@
|
|
|
7831
7813
|
"LayoutAnimationStart",
|
|
7832
7814
|
"LayoutAnimationComplete",
|
|
7833
7815
|
];
|
|
7816
|
+
const numVariantProps = variantProps.length;
|
|
7834
7817
|
/**
|
|
7835
7818
|
* A VisualElement is an imperative abstraction around UI elements such as
|
|
7836
7819
|
* HTMLElement, SVGElement, Three.Object3D etc.
|
|
@@ -8024,8 +8007,8 @@
|
|
|
8024
8007
|
isStrict) {
|
|
8025
8008
|
const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
|
|
8026
8009
|
renderedProps.ignoreStrict
|
|
8027
|
-
? warning(false, strictMessage)
|
|
8028
|
-
: invariant(false, strictMessage);
|
|
8010
|
+
? exports.warning(false, strictMessage)
|
|
8011
|
+
: exports.invariant(false, strictMessage);
|
|
8029
8012
|
}
|
|
8030
8013
|
for (let i = 0; i < numFeatures; i++) {
|
|
8031
8014
|
const name = featureNames[i];
|
|
@@ -8300,8 +8283,6 @@
|
|
|
8300
8283
|
}
|
|
8301
8284
|
}
|
|
8302
8285
|
}
|
|
8303
|
-
const variantProps = ["initial", ...variantPriorityOrder];
|
|
8304
|
-
const numVariantProps = variantProps.length;
|
|
8305
8286
|
|
|
8306
8287
|
class DOMVisualElement extends VisualElement {
|
|
8307
8288
|
sortInstanceNodePosition(a, b) {
|
|
@@ -8357,7 +8338,7 @@
|
|
|
8357
8338
|
}
|
|
8358
8339
|
else {
|
|
8359
8340
|
const computedStyle = getComputedStyle$1(instance);
|
|
8360
|
-
const value = (
|
|
8341
|
+
const value = (isCSSVariableName(key)
|
|
8361
8342
|
? computedStyle.getPropertyValue(key)
|
|
8362
8343
|
: computedStyle[key]) || 0;
|
|
8363
8344
|
return typeof value === "string" ? value.trim() : value;
|
|
@@ -8992,9 +8973,9 @@
|
|
|
8992
8973
|
};
|
|
8993
8974
|
|
|
8994
8975
|
let id = 0;
|
|
8995
|
-
const AnimateSharedLayout = ({ children
|
|
8976
|
+
const AnimateSharedLayout = ({ children }) => {
|
|
8996
8977
|
React__namespace.useEffect(() => {
|
|
8997
|
-
warning(false, "AnimateSharedLayout is deprecated: https://www.framer.com/docs/guide-upgrade/##shared-layout-animations");
|
|
8978
|
+
exports.warning(false, "AnimateSharedLayout is deprecated: https://www.framer.com/docs/guide-upgrade/##shared-layout-animations");
|
|
8998
8979
|
}, []);
|
|
8999
8980
|
return (React__namespace.createElement(LayoutGroup, { id: useConstant(() => `asl-${id++}`) }, children));
|
|
9000
8981
|
};
|
|
@@ -9110,7 +9091,7 @@
|
|
|
9110
9091
|
return order;
|
|
9111
9092
|
const item = order[index];
|
|
9112
9093
|
const nextLayout = nextItem.layout;
|
|
9113
|
-
const nextItemCenter = mix
|
|
9094
|
+
const nextItemCenter = mix(nextLayout.min, nextLayout.max, 0.5);
|
|
9114
9095
|
if ((nextOffset === 1 && item.layout.max + offset > nextItemCenter) ||
|
|
9115
9096
|
(nextOffset === -1 && item.layout.min + offset < nextItemCenter)) {
|
|
9116
9097
|
return moveItem(order, index, index + nextOffset);
|
|
@@ -9122,7 +9103,7 @@
|
|
|
9122
9103
|
const Component = useConstant(() => motion(as));
|
|
9123
9104
|
const order = [];
|
|
9124
9105
|
const isReordering = React.useRef(false);
|
|
9125
|
-
invariant(Boolean(values), "Reorder.Group must be provided a values prop");
|
|
9106
|
+
exports.invariant(Boolean(values), "Reorder.Group must be provided a values prop");
|
|
9126
9107
|
const context = {
|
|
9127
9108
|
axis,
|
|
9128
9109
|
registerItem: (value, layout) => {
|
|
@@ -9204,7 +9185,7 @@
|
|
|
9204
9185
|
const inputRange = args[1 + argOffset];
|
|
9205
9186
|
const outputRange = args[2 + argOffset];
|
|
9206
9187
|
const options = args[3 + argOffset];
|
|
9207
|
-
const interpolator = interpolate
|
|
9188
|
+
const interpolator = interpolate(inputRange, outputRange, {
|
|
9208
9189
|
mixer: getMixer(outputRange[0]),
|
|
9209
9190
|
...options,
|
|
9210
9191
|
});
|
|
@@ -9275,7 +9256,7 @@
|
|
|
9275
9256
|
};
|
|
9276
9257
|
const zIndex = useTransform([point.x, point.y], ([latestX, latestY]) => latestX || latestY ? 1 : "unset");
|
|
9277
9258
|
const measuredLayout = React.useRef(null);
|
|
9278
|
-
invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group");
|
|
9259
|
+
exports.invariant(Boolean(context), "Reorder.Item must be a child of Reorder.Group");
|
|
9279
9260
|
const { axis, registerItem, updateOrder } = context;
|
|
9280
9261
|
React.useEffect(() => {
|
|
9281
9262
|
registerItem(value, measuredLayout.current);
|
|
@@ -9296,6 +9277,17 @@
|
|
|
9296
9277
|
Item,
|
|
9297
9278
|
};
|
|
9298
9279
|
|
|
9280
|
+
exports.AnimationType = void 0;
|
|
9281
|
+
(function (AnimationType) {
|
|
9282
|
+
AnimationType["Animate"] = "animate";
|
|
9283
|
+
AnimationType["Hover"] = "whileHover";
|
|
9284
|
+
AnimationType["Tap"] = "whileTap";
|
|
9285
|
+
AnimationType["Drag"] = "whileDrag";
|
|
9286
|
+
AnimationType["Focus"] = "whileFocus";
|
|
9287
|
+
AnimationType["InView"] = "whileInView";
|
|
9288
|
+
AnimationType["Exit"] = "exit";
|
|
9289
|
+
})(exports.AnimationType || (exports.AnimationType = {}));
|
|
9290
|
+
|
|
9299
9291
|
/**
|
|
9300
9292
|
* @public
|
|
9301
9293
|
*/
|
|
@@ -9431,79 +9423,6 @@
|
|
|
9431
9423
|
return velocity;
|
|
9432
9424
|
}
|
|
9433
9425
|
|
|
9434
|
-
const clamp = (min, max, v) => Math.min(Math.max(v, min), max);
|
|
9435
|
-
|
|
9436
|
-
const isNumber = (value) => typeof value === "number";
|
|
9437
|
-
|
|
9438
|
-
const isEasingList = (easing) => Array.isArray(easing) && !isNumber(easing[0]);
|
|
9439
|
-
|
|
9440
|
-
const wrap$1 = (min, max, v) => {
|
|
9441
|
-
const rangeSize = max - min;
|
|
9442
|
-
return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min;
|
|
9443
|
-
};
|
|
9444
|
-
|
|
9445
|
-
function getEasingForSegment(easing, i) {
|
|
9446
|
-
return isEasingList(easing)
|
|
9447
|
-
? easing[wrap$1(0, easing.length, i)]
|
|
9448
|
-
: easing;
|
|
9449
|
-
}
|
|
9450
|
-
|
|
9451
|
-
const mix = (min, max, progress) => -progress * min + progress * max + min;
|
|
9452
|
-
|
|
9453
|
-
const noopReturn = (v) => v;
|
|
9454
|
-
|
|
9455
|
-
const progress = (min, max, value) => max - min === 0 ? 1 : (value - min) / (max - min);
|
|
9456
|
-
|
|
9457
|
-
function fillOffset(offset, remaining) {
|
|
9458
|
-
const min = offset[offset.length - 1];
|
|
9459
|
-
for (let i = 1; i <= remaining; i++) {
|
|
9460
|
-
const offsetProgress = progress(0, remaining, i);
|
|
9461
|
-
offset.push(mix(min, 1, offsetProgress));
|
|
9462
|
-
}
|
|
9463
|
-
}
|
|
9464
|
-
function defaultOffset$1(length) {
|
|
9465
|
-
const offset = [0];
|
|
9466
|
-
fillOffset(offset, length - 1);
|
|
9467
|
-
return offset;
|
|
9468
|
-
}
|
|
9469
|
-
|
|
9470
|
-
function interpolate(output, input = defaultOffset$1(output.length), easing = noopReturn) {
|
|
9471
|
-
const length = output.length;
|
|
9472
|
-
/**
|
|
9473
|
-
* If the input length is lower than the output we
|
|
9474
|
-
* fill the input to match. This currently assumes the input
|
|
9475
|
-
* is an animation progress value so is a good candidate for
|
|
9476
|
-
* moving outside the function.
|
|
9477
|
-
*/
|
|
9478
|
-
const remainder = length - input.length;
|
|
9479
|
-
remainder > 0 && fillOffset(input, remainder);
|
|
9480
|
-
return (t) => {
|
|
9481
|
-
let i = 0;
|
|
9482
|
-
for (; i < length - 2; i++) {
|
|
9483
|
-
if (t < input[i + 1])
|
|
9484
|
-
break;
|
|
9485
|
-
}
|
|
9486
|
-
let progressInRange = clamp(0, 1, progress(input[i], input[i + 1], t));
|
|
9487
|
-
const segmentEasing = getEasingForSegment(easing, i);
|
|
9488
|
-
progressInRange = segmentEasing(progressInRange);
|
|
9489
|
-
return mix(output[i], output[i + 1], progressInRange);
|
|
9490
|
-
};
|
|
9491
|
-
}
|
|
9492
|
-
|
|
9493
|
-
const isFunction = (value) => typeof value === "function";
|
|
9494
|
-
|
|
9495
|
-
const isString = (value) => typeof value === "string";
|
|
9496
|
-
|
|
9497
|
-
/*
|
|
9498
|
-
Convert velocity into velocity per second
|
|
9499
|
-
|
|
9500
|
-
@param [number]: Unit per frame
|
|
9501
|
-
@param [number]: Frame duration in ms
|
|
9502
|
-
*/
|
|
9503
|
-
function velocityPerSecond(velocity, frameDuration) {
|
|
9504
|
-
return frameDuration ? velocity * (1000 / frameDuration) : 0;
|
|
9505
|
-
}
|
|
9506
|
-
|
|
9507
9426
|
function resolveElements(elements, selectorCache) {
|
|
9508
9427
|
var _a;
|
|
9509
9428
|
if (typeof elements === "string") {
|
|
@@ -9524,82 +9443,6 @@
|
|
|
9524
9443
|
return Array.from(elements || []);
|
|
9525
9444
|
}
|
|
9526
9445
|
|
|
9527
|
-
/******************************************************************************
|
|
9528
|
-
Copyright (c) Microsoft Corporation.
|
|
9529
|
-
|
|
9530
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9531
|
-
purpose with or without fee is hereby granted.
|
|
9532
|
-
|
|
9533
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9534
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9535
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
9536
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
9537
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
9538
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
9539
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
9540
|
-
***************************************************************************** */
|
|
9541
|
-
|
|
9542
|
-
function __rest(s, e) {
|
|
9543
|
-
var t = {};
|
|
9544
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
9545
|
-
t[p] = s[p];
|
|
9546
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
9547
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9548
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9549
|
-
t[p[i]] = s[p[i]];
|
|
9550
|
-
}
|
|
9551
|
-
return t;
|
|
9552
|
-
}
|
|
9553
|
-
|
|
9554
|
-
const thresholds = {
|
|
9555
|
-
any: 0,
|
|
9556
|
-
all: 1,
|
|
9557
|
-
};
|
|
9558
|
-
function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = "any" } = {}) {
|
|
9559
|
-
/**
|
|
9560
|
-
* If this browser doesn't support IntersectionObserver, return a dummy stop function.
|
|
9561
|
-
* Default triggering of onStart is tricky - it could be used for starting/stopping
|
|
9562
|
-
* videos, lazy loading content etc. We could provide an option to enable a fallback, or
|
|
9563
|
-
* provide a fallback callback option.
|
|
9564
|
-
*/
|
|
9565
|
-
if (typeof IntersectionObserver === "undefined") {
|
|
9566
|
-
return () => { };
|
|
9567
|
-
}
|
|
9568
|
-
const elements = resolveElements(elementOrSelector);
|
|
9569
|
-
const activeIntersections = new WeakMap();
|
|
9570
|
-
const onIntersectionChange = (entries) => {
|
|
9571
|
-
entries.forEach((entry) => {
|
|
9572
|
-
const onEnd = activeIntersections.get(entry.target);
|
|
9573
|
-
/**
|
|
9574
|
-
* If there's no change to the intersection, we don't need to
|
|
9575
|
-
* do anything here.
|
|
9576
|
-
*/
|
|
9577
|
-
if (entry.isIntersecting === Boolean(onEnd))
|
|
9578
|
-
return;
|
|
9579
|
-
if (entry.isIntersecting) {
|
|
9580
|
-
const newOnEnd = onStart(entry);
|
|
9581
|
-
if (isFunction(newOnEnd)) {
|
|
9582
|
-
activeIntersections.set(entry.target, newOnEnd);
|
|
9583
|
-
}
|
|
9584
|
-
else {
|
|
9585
|
-
observer.unobserve(entry.target);
|
|
9586
|
-
}
|
|
9587
|
-
}
|
|
9588
|
-
else if (onEnd) {
|
|
9589
|
-
onEnd(entry);
|
|
9590
|
-
activeIntersections.delete(entry.target);
|
|
9591
|
-
}
|
|
9592
|
-
});
|
|
9593
|
-
};
|
|
9594
|
-
const observer = new IntersectionObserver(onIntersectionChange, {
|
|
9595
|
-
root,
|
|
9596
|
-
rootMargin,
|
|
9597
|
-
threshold: typeof amount === "number" ? amount : thresholds[amount],
|
|
9598
|
-
});
|
|
9599
|
-
elements.forEach((element) => observer.observe(element));
|
|
9600
|
-
return () => observer.disconnect();
|
|
9601
|
-
}
|
|
9602
|
-
|
|
9603
9446
|
const resizeHandlers = new WeakMap();
|
|
9604
9447
|
let observer;
|
|
9605
9448
|
function getElementSize(target, borderBoxSize) {
|
|
@@ -9691,7 +9534,7 @@
|
|
|
9691
9534
|
}
|
|
9692
9535
|
|
|
9693
9536
|
function resize(a, b) {
|
|
9694
|
-
return
|
|
9537
|
+
return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
|
|
9695
9538
|
}
|
|
9696
9539
|
|
|
9697
9540
|
/**
|
|
@@ -9736,7 +9579,9 @@
|
|
|
9736
9579
|
axis.progress = progress(0, axis.scrollLength, axis.current);
|
|
9737
9580
|
const elapsed = time - prevTime;
|
|
9738
9581
|
axis.velocity =
|
|
9739
|
-
elapsed > maxElapsed
|
|
9582
|
+
elapsed > maxElapsed
|
|
9583
|
+
? 0
|
|
9584
|
+
: velocityPerSecond(axis.current - prev, elapsed);
|
|
9740
9585
|
}
|
|
9741
9586
|
function updateScrollInfo(element, info, time) {
|
|
9742
9587
|
updateAxisInfo(element, "x", info, time);
|
|
@@ -9804,7 +9649,7 @@
|
|
|
9804
9649
|
/**
|
|
9805
9650
|
* Handle unit values
|
|
9806
9651
|
*/
|
|
9807
|
-
if (
|
|
9652
|
+
if (typeof edge === "string") {
|
|
9808
9653
|
const asNumber = parseFloat(edge);
|
|
9809
9654
|
if (edge.endsWith("px")) {
|
|
9810
9655
|
delta = asNumber;
|
|
@@ -9825,7 +9670,7 @@
|
|
|
9825
9670
|
/**
|
|
9826
9671
|
* If the edge is defined as a number, handle as a progress value.
|
|
9827
9672
|
*/
|
|
9828
|
-
if (
|
|
9673
|
+
if (typeof edge === "number") {
|
|
9829
9674
|
delta = length * edge;
|
|
9830
9675
|
}
|
|
9831
9676
|
return inset + delta;
|
|
@@ -9836,7 +9681,7 @@
|
|
|
9836
9681
|
let offsetDefinition = Array.isArray(offset) ? offset : defaultOffset;
|
|
9837
9682
|
let targetPoint = 0;
|
|
9838
9683
|
let containerPoint = 0;
|
|
9839
|
-
if (
|
|
9684
|
+
if (typeof offset === "number") {
|
|
9840
9685
|
/**
|
|
9841
9686
|
* If we're provided offset: [0, 0.5, 1] then each number x should become
|
|
9842
9687
|
* [x, x], so we default to the behaviour of mapping 0 => 0 of both target
|
|
@@ -9844,7 +9689,7 @@
|
|
|
9844
9689
|
*/
|
|
9845
9690
|
offsetDefinition = [offset, offset];
|
|
9846
9691
|
}
|
|
9847
|
-
else if (
|
|
9692
|
+
else if (typeof offset === "string") {
|
|
9848
9693
|
offset = offset.trim();
|
|
9849
9694
|
if (offset.includes(" ")) {
|
|
9850
9695
|
offsetDefinition = offset.split(" ");
|
|
@@ -9904,7 +9749,7 @@
|
|
|
9904
9749
|
* to map scroll value into a progress.
|
|
9905
9750
|
*/
|
|
9906
9751
|
if (hasChanged) {
|
|
9907
|
-
info[axis].interpolate = interpolate(
|
|
9752
|
+
info[axis].interpolate = interpolate(info[axis].offset, defaultOffset$1(offsetDefinition));
|
|
9908
9753
|
info[axis].interpolatorOffsets = [...info[axis].offset];
|
|
9909
9754
|
}
|
|
9910
9755
|
info[axis].progress = info[axis].interpolate(info[axis].current);
|
|
@@ -9918,7 +9763,7 @@
|
|
|
9918
9763
|
info.y.targetOffset = 0;
|
|
9919
9764
|
if (target !== container) {
|
|
9920
9765
|
let node = target;
|
|
9921
|
-
while (node && node
|
|
9766
|
+
while (node && node !== container) {
|
|
9922
9767
|
info.x.targetOffset += node.offsetLeft;
|
|
9923
9768
|
info.y.targetOffset += node.offsetTop;
|
|
9924
9769
|
node = node.offsetParent;
|
|
@@ -9932,7 +9777,6 @@
|
|
|
9932
9777
|
info.y.containerLength = container.clientHeight;
|
|
9933
9778
|
}
|
|
9934
9779
|
function createOnScrollHandler(element, onScroll, info, options = {}) {
|
|
9935
|
-
const axis = options.axis || "y";
|
|
9936
9780
|
return {
|
|
9937
9781
|
measure: () => measure(element, options.target, info),
|
|
9938
9782
|
update: (time) => {
|
|
@@ -9941,29 +9785,7 @@
|
|
|
9941
9785
|
resolveOffsets(element, info, options);
|
|
9942
9786
|
}
|
|
9943
9787
|
},
|
|
9944
|
-
notify:
|
|
9945
|
-
? () => onScroll(info)
|
|
9946
|
-
: scrubAnimation(onScroll, info[axis]),
|
|
9947
|
-
};
|
|
9948
|
-
}
|
|
9949
|
-
function scrubAnimation(controls, axisInfo) {
|
|
9950
|
-
controls.pause();
|
|
9951
|
-
controls.forEachNative((animation, { easing }) => {
|
|
9952
|
-
var _a, _b;
|
|
9953
|
-
if (animation.updateDuration) {
|
|
9954
|
-
if (!easing)
|
|
9955
|
-
animation.easing = noopReturn;
|
|
9956
|
-
animation.updateDuration(1);
|
|
9957
|
-
}
|
|
9958
|
-
else {
|
|
9959
|
-
const timingOptions = { duration: 1000 };
|
|
9960
|
-
if (!easing)
|
|
9961
|
-
timingOptions.easing = "linear";
|
|
9962
|
-
(_b = (_a = animation.effect) === null || _a === void 0 ? void 0 : _a.updateTiming) === null || _b === void 0 ? void 0 : _b.call(_a, timingOptions);
|
|
9963
|
-
}
|
|
9964
|
-
});
|
|
9965
|
-
return () => {
|
|
9966
|
-
controls.currentTime = axisInfo.progress;
|
|
9788
|
+
notify: () => onScroll(info),
|
|
9967
9789
|
};
|
|
9968
9790
|
}
|
|
9969
9791
|
|
|
@@ -9971,8 +9793,7 @@
|
|
|
9971
9793
|
const resizeListeners = new WeakMap();
|
|
9972
9794
|
const onScrollHandlers = new WeakMap();
|
|
9973
9795
|
const getEventTarget = (element) => element === document.documentElement ? window : element;
|
|
9974
|
-
function scroll(onScroll,
|
|
9975
|
-
var { container = document.documentElement } = _a, options = __rest(_a, ["container"]);
|
|
9796
|
+
function scroll(onScroll, { container = document.documentElement, ...options } = {}) {
|
|
9976
9797
|
let containerHandlers = onScrollHandlers.get(container);
|
|
9977
9798
|
/**
|
|
9978
9799
|
* Get the onScroll handlers for this container.
|
|
@@ -10014,33 +9835,31 @@
|
|
|
10014
9835
|
const onLoadProcesss = requestAnimationFrame(listener);
|
|
10015
9836
|
return () => {
|
|
10016
9837
|
var _a;
|
|
10017
|
-
if (typeof onScroll !== "function")
|
|
10018
|
-
onScroll.stop();
|
|
10019
9838
|
cancelAnimationFrame(onLoadProcesss);
|
|
10020
9839
|
/**
|
|
10021
9840
|
* Check if we even have any handlers for this container.
|
|
10022
9841
|
*/
|
|
10023
|
-
const
|
|
10024
|
-
if (!
|
|
9842
|
+
const currentHandlers = onScrollHandlers.get(container);
|
|
9843
|
+
if (!currentHandlers)
|
|
10025
9844
|
return;
|
|
10026
|
-
|
|
10027
|
-
if (
|
|
9845
|
+
currentHandlers.delete(containerHandler);
|
|
9846
|
+
if (currentHandlers.size)
|
|
10028
9847
|
return;
|
|
10029
9848
|
/**
|
|
10030
9849
|
* If no more handlers, remove the scroll listener too.
|
|
10031
9850
|
*/
|
|
10032
|
-
const
|
|
9851
|
+
const scrollListener = scrollListeners.get(container);
|
|
10033
9852
|
scrollListeners.delete(container);
|
|
10034
|
-
if (
|
|
10035
|
-
getEventTarget(container).removeEventListener("scroll",
|
|
9853
|
+
if (scrollListener) {
|
|
9854
|
+
getEventTarget(container).removeEventListener("scroll", scrollListener);
|
|
10036
9855
|
(_a = resizeListeners.get(container)) === null || _a === void 0 ? void 0 : _a();
|
|
10037
|
-
window.removeEventListener("resize",
|
|
9856
|
+
window.removeEventListener("resize", scrollListener);
|
|
10038
9857
|
}
|
|
10039
9858
|
};
|
|
10040
9859
|
}
|
|
10041
9860
|
|
|
10042
9861
|
function refWarning(name, ref) {
|
|
10043
|
-
warning(Boolean(!ref || ref.current), `You have defined a ${name} options but the provided ref is not yet hydrated, probably because it's defined higher up the tree. Try calling useScroll() in the same component as the ref, or setting its \`layoutEffect: false\` option.`);
|
|
9862
|
+
exports.warning(Boolean(!ref || ref.current), `You have defined a ${name} options but the provided ref is not yet hydrated, probably because it's defined higher up the tree. Try calling useScroll() in the same component as the ref, or setting its \`layoutEffect: false\` option.`);
|
|
10044
9863
|
}
|
|
10045
9864
|
const createScrollMotionValues = () => ({
|
|
10046
9865
|
scrollX: motionValue(0),
|
|
@@ -10125,7 +9944,7 @@
|
|
|
10125
9944
|
memberName = "transform";
|
|
10126
9945
|
}
|
|
10127
9946
|
else if (!name.startsWith("origin") &&
|
|
10128
|
-
!
|
|
9947
|
+
!isCSSVariableName(name) &&
|
|
10129
9948
|
name !== "willChange") {
|
|
10130
9949
|
memberName = camelToDash(name);
|
|
10131
9950
|
}
|
|
@@ -10237,7 +10056,7 @@
|
|
|
10237
10056
|
return () => void subscribers.delete(visualElement);
|
|
10238
10057
|
},
|
|
10239
10058
|
start(definition, transitionOverride) {
|
|
10240
|
-
invariant(hasMounted, "controls.start() should only be called after a component has mounted. Consider calling within a useEffect hook.");
|
|
10059
|
+
exports.invariant(hasMounted, "controls.start() should only be called after a component has mounted. Consider calling within a useEffect hook.");
|
|
10241
10060
|
const animations = [];
|
|
10242
10061
|
subscribers.forEach((visualElement) => {
|
|
10243
10062
|
animations.push(animateVisualElement(visualElement, definition, {
|
|
@@ -10247,7 +10066,7 @@
|
|
|
10247
10066
|
return Promise.all(animations);
|
|
10248
10067
|
},
|
|
10249
10068
|
set(definition) {
|
|
10250
|
-
invariant(hasMounted, "controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook.");
|
|
10069
|
+
exports.invariant(hasMounted, "controls.set() should only be called after a component has mounted. Consider calling within a useEffect hook.");
|
|
10251
10070
|
return subscribers.forEach((visualElement) => {
|
|
10252
10071
|
setValues(visualElement, definition);
|
|
10253
10072
|
});
|
|
@@ -10352,6 +10171,55 @@
|
|
|
10352
10171
|
return [item, runCycle];
|
|
10353
10172
|
}
|
|
10354
10173
|
|
|
10174
|
+
const thresholds = {
|
|
10175
|
+
any: 0,
|
|
10176
|
+
all: 1,
|
|
10177
|
+
};
|
|
10178
|
+
function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = "any" } = {}) {
|
|
10179
|
+
/**
|
|
10180
|
+
* If this browser doesn't support IntersectionObserver, return a dummy stop function.
|
|
10181
|
+
* Default triggering of onStart is tricky - it could be used for starting/stopping
|
|
10182
|
+
* videos, lazy loading content etc. We could provide an option to enable a fallback, or
|
|
10183
|
+
* provide a fallback callback option.
|
|
10184
|
+
*/
|
|
10185
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
10186
|
+
return () => { };
|
|
10187
|
+
}
|
|
10188
|
+
const elements = resolveElements(elementOrSelector);
|
|
10189
|
+
const activeIntersections = new WeakMap();
|
|
10190
|
+
const onIntersectionChange = (entries) => {
|
|
10191
|
+
entries.forEach((entry) => {
|
|
10192
|
+
const onEnd = activeIntersections.get(entry.target);
|
|
10193
|
+
/**
|
|
10194
|
+
* If there's no change to the intersection, we don't need to
|
|
10195
|
+
* do anything here.
|
|
10196
|
+
*/
|
|
10197
|
+
if (entry.isIntersecting === Boolean(onEnd))
|
|
10198
|
+
return;
|
|
10199
|
+
if (entry.isIntersecting) {
|
|
10200
|
+
const newOnEnd = onStart(entry);
|
|
10201
|
+
if (typeof newOnEnd === "function") {
|
|
10202
|
+
activeIntersections.set(entry.target, newOnEnd);
|
|
10203
|
+
}
|
|
10204
|
+
else {
|
|
10205
|
+
observer.unobserve(entry.target);
|
|
10206
|
+
}
|
|
10207
|
+
}
|
|
10208
|
+
else if (onEnd) {
|
|
10209
|
+
onEnd(entry);
|
|
10210
|
+
activeIntersections.delete(entry.target);
|
|
10211
|
+
}
|
|
10212
|
+
});
|
|
10213
|
+
};
|
|
10214
|
+
const observer = new IntersectionObserver(onIntersectionChange, {
|
|
10215
|
+
root,
|
|
10216
|
+
rootMargin,
|
|
10217
|
+
threshold: typeof amount === "number" ? amount : thresholds[amount],
|
|
10218
|
+
});
|
|
10219
|
+
elements.forEach((element) => observer.observe(element));
|
|
10220
|
+
return () => observer.disconnect();
|
|
10221
|
+
}
|
|
10222
|
+
|
|
10355
10223
|
function useInView(ref, { root, margin, amount, once = false } = {}) {
|
|
10356
10224
|
const [isInView, setInView] = React.useState(false);
|
|
10357
10225
|
React.useEffect(() => {
|
|
@@ -10747,8 +10615,8 @@
|
|
|
10747
10615
|
let parentScaleX = useMotionValue(1);
|
|
10748
10616
|
let parentScaleY = useMotionValue(1);
|
|
10749
10617
|
const visualElement = useVisualElementContext();
|
|
10750
|
-
invariant(!!(scale || visualElement), "If no scale values are provided, useInvertedScale must be used within a child of another motion component.");
|
|
10751
|
-
warning(hasWarned, "useInvertedScale is deprecated and will be removed in 3.0. Use the layout prop instead.");
|
|
10618
|
+
exports.invariant(!!(scale || visualElement), "If no scale values are provided, useInvertedScale must be used within a child of another motion component.");
|
|
10619
|
+
exports.warning(hasWarned, "useInvertedScale is deprecated and will be removed in 3.0. Use the layout prop instead.");
|
|
10752
10620
|
hasWarned = true;
|
|
10753
10621
|
if (scale) {
|
|
10754
10622
|
parentScaleX = scale.scaleX || parentScaleX;
|
|
@@ -10797,7 +10665,7 @@
|
|
|
10797
10665
|
exports.circIn = circIn;
|
|
10798
10666
|
exports.circInOut = circInOut;
|
|
10799
10667
|
exports.circOut = circOut;
|
|
10800
|
-
exports.clamp = clamp
|
|
10668
|
+
exports.clamp = clamp;
|
|
10801
10669
|
exports.color = color;
|
|
10802
10670
|
exports.complex = complex;
|
|
10803
10671
|
exports.createBox = createBox;
|
|
@@ -10815,7 +10683,7 @@
|
|
|
10815
10683
|
exports.filterProps = filterProps;
|
|
10816
10684
|
exports.frameData = frameData;
|
|
10817
10685
|
exports.inertia = inertia;
|
|
10818
|
-
exports.interpolate = interpolate
|
|
10686
|
+
exports.interpolate = interpolate;
|
|
10819
10687
|
exports.isBrowser = isBrowser;
|
|
10820
10688
|
exports.isDragActive = isDragActive;
|
|
10821
10689
|
exports.isMotionComponent = isMotionComponent;
|
|
@@ -10823,12 +10691,12 @@
|
|
|
10823
10691
|
exports.isValidMotionProp = isValidMotionProp;
|
|
10824
10692
|
exports.m = m;
|
|
10825
10693
|
exports.makeUseVisualState = makeUseVisualState;
|
|
10826
|
-
exports.mix = mix
|
|
10694
|
+
exports.mix = mix;
|
|
10827
10695
|
exports.motion = motion;
|
|
10828
10696
|
exports.motionValue = motionValue;
|
|
10829
10697
|
exports.optimizedAppearDataAttribute = optimizedAppearDataAttribute;
|
|
10830
10698
|
exports.pipe = pipe;
|
|
10831
|
-
exports.progress = progress
|
|
10699
|
+
exports.progress = progress;
|
|
10832
10700
|
exports.px = px;
|
|
10833
10701
|
exports.resolveMotionValue = resolveMotionValue;
|
|
10834
10702
|
exports.spring = spring;
|