framer-motion 12.7.4 → 12.7.5-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/client.js +1 -1
- package/dist/cjs/{create-BErHrlzf.js → create-D5a67TOR.js} +99 -2828
- package/dist/cjs/dom-mini.js +82 -66
- package/dist/cjs/dom.js +276 -3011
- package/dist/cjs/index.js +149 -206
- package/dist/cjs/m.js +13 -170
- package/dist/cjs/mini.js +77 -9
- package/dist/dom-mini.js +1 -1
- package/dist/dom.d.ts +5 -94
- package/dist/dom.js +1 -1
- package/dist/es/animation/animate/sequence.mjs +1 -1
- package/dist/es/animation/animators/waapi/animate-elements.mjs +78 -10
- package/dist/es/animation/interfaces/motion-value.mjs +11 -30
- package/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
- package/dist/es/animation/optimized-appear/store-id.mjs +1 -1
- package/dist/es/animation/sequence/create.mjs +2 -5
- package/dist/es/animation/sequence/utils/edit.mjs +2 -3
- package/dist/es/animation/utils/default-transitions.mjs +1 -1
- package/dist/es/animation/utils/stagger.mjs +1 -1
- package/dist/es/components/Reorder/utils/check-reorder.mjs +1 -1
- package/dist/es/dom.mjs +2 -18
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +1 -3
- package/dist/es/gestures/drag/utils/constraints.mjs +2 -3
- package/dist/es/gestures/focus.mjs +1 -1
- package/dist/es/gestures/pan/PanSession.mjs +1 -2
- package/dist/es/index.mjs +3 -24
- package/dist/es/motion/utils/is-forced-motion-value.mjs +1 -1
- package/dist/es/projection/animation/mix-values.mjs +2 -4
- package/dist/es/projection/geometry/delta-apply.mjs +1 -1
- package/dist/es/projection/geometry/delta-calc.mjs +1 -1
- package/dist/es/projection/geometry/delta-remove.mjs +1 -2
- package/dist/es/projection/node/create-projection-node.mjs +3 -7
- package/dist/es/projection/styles/scale-border-radius.mjs +1 -1
- package/dist/es/projection/styles/scale-box-shadow.mjs +1 -2
- package/dist/es/projection/styles/scale-correction.mjs +1 -1
- package/dist/es/projection.mjs +1 -3
- package/dist/es/render/VisualElement.mjs +2 -9
- package/dist/es/render/dom/DOMVisualElement.mjs +1 -1
- package/dist/es/render/dom/scroll/attach-animation.mjs +17 -0
- package/dist/es/render/dom/scroll/attach-function.mjs +23 -0
- package/dist/es/render/dom/scroll/index.mjs +6 -82
- package/dist/es/render/dom/scroll/offsets/index.mjs +2 -3
- package/dist/es/render/dom/scroll/utils/get-timeline.mjs +30 -0
- package/dist/es/render/html/HTMLVisualElement.mjs +1 -3
- package/dist/es/render/html/utils/build-styles.mjs +1 -4
- package/dist/es/render/html/utils/build-transform.mjs +1 -3
- package/dist/es/render/svg/SVGVisualElement.mjs +1 -3
- package/dist/es/render/svg/config-motion.mjs +1 -2
- package/dist/es/render/svg/utils/path.mjs +1 -1
- package/dist/es/render/svg/utils/scrape-motion-values.mjs +1 -1
- package/dist/es/render/svg/utils/transform-origin.mjs +1 -1
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/utils/delay.mjs +1 -1
- package/dist/es/utils/transform.mjs +1 -1
- package/dist/es/utils/use-cycle.mjs +1 -1
- package/dist/es/utils/use-instant-transition.mjs +4 -4
- package/dist/es/value/use-spring.mjs +2 -3
- package/dist/es/value/use-will-change/get-will-change-name.mjs +1 -2
- package/dist/framer-motion.dev.js +3864 -3405
- package/dist/framer-motion.js +1 -1
- package/dist/m.d.ts +3 -50
- package/dist/mini.js +1 -1
- package/dist/size-rollup-animate.js +1 -1
- 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-rollup-scroll.js +1 -1
- package/dist/size-rollup-waapi-animate.js +1 -1
- package/dist/types/client.d.ts +4 -3
- package/dist/types/index.d.ts +56 -351
- package/dist/{types.d-B50aGbjN.d.ts → types.d-B1Voffvi.d.ts} +3 -138
- package/package.json +9 -9
- package/dist/es/animation/animators/AcceleratedAnimation.mjs +0 -319
- package/dist/es/animation/animators/BaseAnimation.mjs +0 -120
- package/dist/es/animation/animators/MainThreadAnimation.mjs +0 -394
- package/dist/es/animation/animators/drivers/driver-frameloop.mjs +0 -16
- package/dist/es/animation/animators/utils/accelerated-values.mjs +0 -14
- package/dist/es/animation/animators/utils/can-animate.mjs +0 -42
- package/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +0 -5
- package/dist/es/animation/generators/inertia.mjs +0 -87
- package/dist/es/animation/generators/keyframes.mjs +0 -51
- package/dist/es/animation/generators/spring/defaults.mjs +0 -27
- package/dist/es/animation/generators/spring/find.mjs +0 -85
- package/dist/es/animation/generators/spring/index.mjs +0 -174
- package/dist/es/animation/generators/utils/velocity.mjs +0 -9
- package/dist/es/animation/utils/is-animatable.mjs +0 -30
- package/dist/es/animation/utils/is-none.mjs +0 -15
- package/dist/es/easing/anticipate.mjs +0 -5
- package/dist/es/easing/back.mjs +0 -9
- package/dist/es/easing/circ.mjs +0 -8
- package/dist/es/easing/cubic-bezier.mjs +0 -51
- package/dist/es/easing/ease.mjs +0 -7
- package/dist/es/easing/modifiers/mirror.mjs +0 -5
- package/dist/es/easing/modifiers/reverse.mjs +0 -5
- package/dist/es/easing/steps.mjs +0 -15
- package/dist/es/easing/utils/get-easing-for-segment.mjs +0 -8
- package/dist/es/easing/utils/is-easing-array.mjs +0 -5
- package/dist/es/easing/utils/map.mjs +0 -37
- package/dist/es/render/dom/DOMKeyframesResolver.mjs +0 -130
- package/dist/es/render/dom/scroll/observe.mjs +0 -18
- package/dist/es/render/dom/utils/css-variables-conversion.mjs +0 -42
- package/dist/es/render/dom/utils/is-css-variable.mjs +0 -15
- package/dist/es/render/dom/utils/unit-conversion.mjs +0 -36
- package/dist/es/render/dom/value-types/animatable-none.mjs +0 -15
- package/dist/es/render/dom/value-types/defaults.mjs +0 -30
- package/dist/es/render/dom/value-types/dimensions.mjs +0 -15
- package/dist/es/render/dom/value-types/find.mjs +0 -15
- package/dist/es/render/dom/value-types/get-as-type.mjs +0 -10
- package/dist/es/render/dom/value-types/number-browser.mjs +0 -41
- package/dist/es/render/dom/value-types/number.mjs +0 -18
- package/dist/es/render/dom/value-types/test.mjs +0 -6
- package/dist/es/render/dom/value-types/transform.mjs +0 -31
- package/dist/es/render/dom/value-types/type-auto.mjs +0 -9
- package/dist/es/render/dom/value-types/type-int.mjs +0 -8
- package/dist/es/render/html/utils/keys-position.mjs +0 -13
- package/dist/es/render/html/utils/keys-transform.mjs +0 -28
- package/dist/es/render/html/utils/make-none-animatable.mjs +0 -30
- package/dist/es/render/html/utils/parse-transform.mjs +0 -83
- package/dist/es/render/utils/KeyframesResolver.mjs +0 -163
- package/dist/es/utils/clamp.mjs +0 -9
- package/dist/es/utils/hsla-to-rgba.mjs +0 -42
- package/dist/es/utils/interpolate.mjs +0 -76
- package/dist/es/utils/is-numerical-string.mjs +0 -6
- package/dist/es/utils/is-zero-value-string.mjs +0 -6
- package/dist/es/utils/mix/color.mjs +0 -47
- package/dist/es/utils/mix/complex.mjs +0 -93
- package/dist/es/utils/mix/immediate.mjs +0 -5
- package/dist/es/utils/mix/index.mjs +0 -14
- package/dist/es/utils/mix/number.mjs +0 -26
- package/dist/es/utils/mix/visibility.mjs +0 -16
- package/dist/es/utils/offsets/default.mjs +0 -9
- package/dist/es/utils/offsets/fill.mjs +0 -12
- package/dist/es/utils/offsets/time.mjs +0 -5
- package/dist/es/utils/pipe.mjs +0 -11
- package/dist/es/utils/use-instant-transition-state.mjs +0 -5
- package/dist/es/utils/wrap.mjs +0 -6
- package/dist/es/value/types/color/hex.mjs +0 -40
- package/dist/es/value/types/color/hsla.mjs +0 -22
- package/dist/es/value/types/color/index.mjs +0 -27
- package/dist/es/value/types/color/rgba.mjs +0 -25
- package/dist/es/value/types/color/utils.mjs +0 -29
- package/dist/es/value/types/complex/filter.mjs +0 -30
- package/dist/es/value/types/complex/index.mjs +0 -91
- package/dist/es/value/types/numbers/index.mjs +0 -17
- package/dist/es/value/types/numbers/units.mjs +0 -17
- package/dist/es/value/types/utils/color-regex.mjs +0 -3
- package/dist/es/value/types/utils/float-regex.mjs +0 -3
- package/dist/es/value/types/utils/is-nullish.mjs +0 -5
- package/dist/es/value/types/utils/sanitize.mjs +0 -5
- package/dist/es/value/types/utils/single-color-regex.mjs +0 -3
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-D5a67TOR.js');
|
|
8
8
|
var motionDom = require('motion-dom');
|
|
9
9
|
var motionUtils = require('motion-utils');
|
|
10
10
|
|
|
@@ -553,7 +553,7 @@ function checkReorder(order, value, offset, velocity) {
|
|
|
553
553
|
return order;
|
|
554
554
|
const item = order[index];
|
|
555
555
|
const nextLayout = nextItem.layout;
|
|
556
|
-
const nextItemCenter =
|
|
556
|
+
const nextItemCenter = motionDom.mixNumber(nextLayout.min, nextLayout.max, 0.5);
|
|
557
557
|
if ((nextOffset === 1 && item.layout.max + offset > nextItemCenter) ||
|
|
558
558
|
(nextOffset === -1 && item.layout.min + offset < nextItemCenter)) {
|
|
559
559
|
return motionUtils.moveItem(order, index, index + nextOffset);
|
|
@@ -647,7 +647,7 @@ function transform(...args) {
|
|
|
647
647
|
const inputRange = args[1 + argOffset];
|
|
648
648
|
const outputRange = args[2 + argOffset];
|
|
649
649
|
const options = args[3 + argOffset];
|
|
650
|
-
const interpolator =
|
|
650
|
+
const interpolator = motionDom.interpolate(inputRange, outputRange, {
|
|
651
651
|
mixer: getMixer(outputRange[0]),
|
|
652
652
|
...options,
|
|
653
653
|
});
|
|
@@ -752,15 +752,6 @@ var namespace = /*#__PURE__*/Object.freeze({
|
|
|
752
752
|
Item: ReorderItem
|
|
753
753
|
});
|
|
754
754
|
|
|
755
|
-
const wrap = (min, max, v) => {
|
|
756
|
-
const rangeSize = max - min;
|
|
757
|
-
return ((((v - min) % rangeSize) + rangeSize) % rangeSize) + min;
|
|
758
|
-
};
|
|
759
|
-
|
|
760
|
-
function getEasingForSegment(easing, i) {
|
|
761
|
-
return create.isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
|
|
762
|
-
}
|
|
763
|
-
|
|
764
755
|
function isDOMKeyframes(keyframes) {
|
|
765
756
|
return typeof keyframes === "object" && !Array.isArray(keyframes);
|
|
766
757
|
}
|
|
@@ -823,8 +814,8 @@ function addKeyframes(sequence, keyframes, easing, offset, startTime, endTime) {
|
|
|
823
814
|
for (let i = 0; i < keyframes.length; i++) {
|
|
824
815
|
sequence.push({
|
|
825
816
|
value: keyframes[i],
|
|
826
|
-
at:
|
|
827
|
-
easing: getEasingForSegment(easing, i),
|
|
817
|
+
at: motionDom.mixNumber(startTime, endTime, offset[i]),
|
|
818
|
+
easing: motionUtils.getEasingForSegment(easing, i),
|
|
828
819
|
});
|
|
829
820
|
}
|
|
830
821
|
}
|
|
@@ -898,7 +889,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
898
889
|
let maxDuration = 0;
|
|
899
890
|
const resolveValueSequence = (valueKeyframes, valueTransition, valueSequence, elementIndex = 0, numSubjects = 0) => {
|
|
900
891
|
const valueKeyframesAsList = keyframesAsList(valueKeyframes);
|
|
901
|
-
const { delay = 0, times =
|
|
892
|
+
const { delay = 0, times = motionDom.defaultOffset(valueKeyframesAsList), type = "keyframes", repeat, repeatType, repeatDelay = 0, ...remainingTransition } = valueTransition;
|
|
902
893
|
let { ease = defaultTransition.ease || "easeOut", duration } = valueTransition;
|
|
903
894
|
/**
|
|
904
895
|
* Resolve stagger() if defined.
|
|
@@ -946,7 +937,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
946
937
|
* Fill out if offset if fewer offsets than keyframes
|
|
947
938
|
*/
|
|
948
939
|
const remainder = times.length - valueKeyframesAsList.length;
|
|
949
|
-
remainder > 0 &&
|
|
940
|
+
remainder > 0 && motionDom.fillOffset(times, remainder);
|
|
950
941
|
/**
|
|
951
942
|
* If only one value has been set, ie [1], push a null to the start of
|
|
952
943
|
* the keyframe array. This will let us mark a keyframe at this point
|
|
@@ -970,7 +961,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
970
961
|
times.push(originalTimes[keyframeIndex] + (repeatIndex + 1));
|
|
971
962
|
ease.push(keyframeIndex === 0
|
|
972
963
|
? "linear"
|
|
973
|
-
: getEasingForSegment(originalEase, keyframeIndex - 1));
|
|
964
|
+
: motionUtils.getEasingForSegment(originalEase, keyframeIndex - 1));
|
|
974
965
|
}
|
|
975
966
|
}
|
|
976
967
|
normalizeTimes(times, repeat);
|
|
@@ -1211,7 +1202,7 @@ function animateSubject(subject, keyframes, options, scope) {
|
|
|
1211
1202
|
|
|
1212
1203
|
function animateSequence(sequence, options, scope) {
|
|
1213
1204
|
const animations = [];
|
|
1214
|
-
const animationDefinitions = createAnimationsFromSequence(sequence, options, scope, { spring:
|
|
1205
|
+
const animationDefinitions = createAnimationsFromSequence(sequence, options, scope, { spring: motionDom.spring });
|
|
1215
1206
|
animationDefinitions.forEach(({ keyframes, transition }, subject) => {
|
|
1216
1207
|
animations.push(...animateSubject(subject, keyframes, transition));
|
|
1217
1208
|
});
|
|
@@ -1251,7 +1242,27 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
1251
1242
|
const elements = motionDom.resolveElements(elementOrSelector, scope);
|
|
1252
1243
|
const numElements = elements.length;
|
|
1253
1244
|
motionUtils.invariant(Boolean(numElements), "No valid element provided.");
|
|
1254
|
-
|
|
1245
|
+
/**
|
|
1246
|
+
* WAAPI doesn't support interrupting animations.
|
|
1247
|
+
*
|
|
1248
|
+
* Therefore, starting animations requires a three-step process:
|
|
1249
|
+
* 1. Stop existing animations (write styles to DOM)
|
|
1250
|
+
* 2. Resolve keyframes (read styles from DOM)
|
|
1251
|
+
* 3. Create new animations (write styles to DOM)
|
|
1252
|
+
*
|
|
1253
|
+
* The hybrid `animate()` function uses AsyncAnimation to resolve
|
|
1254
|
+
* keyframes before creating new animations, which removes style
|
|
1255
|
+
* thrashing. Here, we have much stricter filesize constraints.
|
|
1256
|
+
* Therefore we do this in a synchronous way that ensures that
|
|
1257
|
+
* at least within `animate()` calls there is no style thrashing.
|
|
1258
|
+
*
|
|
1259
|
+
* In the motion-native-animate-mini-interrupt benchmark this
|
|
1260
|
+
* was 80% faster than a single loop.
|
|
1261
|
+
*/
|
|
1262
|
+
const animationDefinitions = [];
|
|
1263
|
+
/**
|
|
1264
|
+
* Step 1: Build options and stop existing animations (write)
|
|
1265
|
+
*/
|
|
1255
1266
|
for (let i = 0; i < numElements; i++) {
|
|
1256
1267
|
const element = elements[i];
|
|
1257
1268
|
const elementTransition = { ...options };
|
|
@@ -1262,21 +1273,69 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
1262
1273
|
elementTransition.delay = elementTransition.delay(i, numElements);
|
|
1263
1274
|
}
|
|
1264
1275
|
for (const valueName in keyframes) {
|
|
1265
|
-
|
|
1276
|
+
let valueKeyframes = keyframes[valueName];
|
|
1277
|
+
if (!Array.isArray(valueKeyframes)) {
|
|
1278
|
+
valueKeyframes = [valueKeyframes];
|
|
1279
|
+
}
|
|
1266
1280
|
const valueOptions = {
|
|
1267
1281
|
...motionDom.getValueTransition(elementTransition, valueName),
|
|
1268
1282
|
};
|
|
1269
1283
|
valueOptions.duration && (valueOptions.duration = motionUtils.secondsToMilliseconds(valueOptions.duration));
|
|
1270
1284
|
valueOptions.delay && (valueOptions.delay = motionUtils.secondsToMilliseconds(valueOptions.delay));
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1285
|
+
/**
|
|
1286
|
+
* If there's an existing animation playing on this element then stop it
|
|
1287
|
+
* before creating a new one.
|
|
1288
|
+
*/
|
|
1289
|
+
const map = motionDom.getAnimationMap(element);
|
|
1290
|
+
const key = motionDom.animationMapKey(valueName, valueOptions.pseudoElement || "");
|
|
1291
|
+
const currentAnimation = map.get(key);
|
|
1292
|
+
currentAnimation && currentAnimation.stop();
|
|
1293
|
+
animationDefinitions.push({
|
|
1294
|
+
map,
|
|
1295
|
+
key,
|
|
1296
|
+
unresolvedKeyframes: valueKeyframes,
|
|
1297
|
+
options: {
|
|
1298
|
+
...valueOptions,
|
|
1299
|
+
element,
|
|
1300
|
+
name: valueName,
|
|
1301
|
+
allowFlatten: !elementTransition.type && !elementTransition.ease,
|
|
1302
|
+
},
|
|
1303
|
+
});
|
|
1278
1304
|
}
|
|
1279
1305
|
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Step 2: Resolve keyframes (read)
|
|
1308
|
+
*/
|
|
1309
|
+
for (let i = 0; i < animationDefinitions.length; i++) {
|
|
1310
|
+
const { unresolvedKeyframes, options: animationOptions } = animationDefinitions[i];
|
|
1311
|
+
const { element, name, pseudoElement } = animationOptions;
|
|
1312
|
+
if (!pseudoElement && unresolvedKeyframes[0] === null) {
|
|
1313
|
+
unresolvedKeyframes[0] = motionDom.getComputedStyle(element, name);
|
|
1314
|
+
}
|
|
1315
|
+
motionDom.fillWildcards(unresolvedKeyframes);
|
|
1316
|
+
motionDom.applyPxDefaults(unresolvedKeyframes, name);
|
|
1317
|
+
/**
|
|
1318
|
+
* If we only have one keyframe, explicitly read the initial keyframe
|
|
1319
|
+
* from the computed style. This is to ensure consistency with WAAPI behaviour
|
|
1320
|
+
* for restarting animations, for instance .play() after finish, when it
|
|
1321
|
+
* has one vs two keyframes.
|
|
1322
|
+
*/
|
|
1323
|
+
if (!pseudoElement && unresolvedKeyframes.length < 2) {
|
|
1324
|
+
unresolvedKeyframes.unshift(motionDom.getComputedStyle(element, name));
|
|
1325
|
+
}
|
|
1326
|
+
animationOptions.keyframes = unresolvedKeyframes;
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Step 3: Create new animations (write)
|
|
1330
|
+
*/
|
|
1331
|
+
const animations = [];
|
|
1332
|
+
for (let i = 0; i < animationDefinitions.length; i++) {
|
|
1333
|
+
const { map, key, options: animationOptions } = animationDefinitions[i];
|
|
1334
|
+
const animation = new motionDom.NativeAnimation(animationOptions);
|
|
1335
|
+
map.set(key, animation);
|
|
1336
|
+
animation.finished.finally(() => map.delete(key));
|
|
1337
|
+
animations.push(animation);
|
|
1338
|
+
}
|
|
1280
1339
|
return animations;
|
|
1281
1340
|
}
|
|
1282
1341
|
|
|
@@ -1288,21 +1347,6 @@ const createScopedWaapiAnimate = (scope) => {
|
|
|
1288
1347
|
};
|
|
1289
1348
|
const animateMini = /*@__PURE__*/ createScopedWaapiAnimate();
|
|
1290
1349
|
|
|
1291
|
-
function observeTimeline(update, timeline) {
|
|
1292
|
-
let prevProgress;
|
|
1293
|
-
const onFrame = () => {
|
|
1294
|
-
const { currentTime } = timeline;
|
|
1295
|
-
const percentage = currentTime === null ? 0 : currentTime.value;
|
|
1296
|
-
const progress = percentage / 100;
|
|
1297
|
-
if (prevProgress !== progress) {
|
|
1298
|
-
update(progress);
|
|
1299
|
-
}
|
|
1300
|
-
prevProgress = progress;
|
|
1301
|
-
};
|
|
1302
|
-
motionDom.frame.update(onFrame, true);
|
|
1303
|
-
return () => motionDom.cancelFrame(onFrame);
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
1350
|
const resizeHandlers = new WeakMap();
|
|
1307
1351
|
let observer;
|
|
1308
1352
|
function getElementSize(target, borderBoxSize) {
|
|
@@ -1633,10 +1677,10 @@ function resolveOffsets(container, info, options) {
|
|
|
1633
1677
|
* to map scroll value into a progress.
|
|
1634
1678
|
*/
|
|
1635
1679
|
if (hasChanged) {
|
|
1636
|
-
info[axis].interpolate =
|
|
1680
|
+
info[axis].interpolate = motionDom.interpolate(info[axis].offset, motionDom.defaultOffset(offsetDefinition), { clamp: false });
|
|
1637
1681
|
info[axis].interpolatorOffsets = [...info[axis].offset];
|
|
1638
1682
|
}
|
|
1639
|
-
info[axis].progress =
|
|
1683
|
+
info[axis].progress = motionUtils.clamp(0, 1, info[axis].interpolate(info[axis].current));
|
|
1640
1684
|
}
|
|
1641
1685
|
|
|
1642
1686
|
function measure(container, target = container, info) {
|
|
@@ -1759,33 +1803,45 @@ function scrollInfo(onScroll, { container = document.documentElement, ...options
|
|
|
1759
1803
|
};
|
|
1760
1804
|
}
|
|
1761
1805
|
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
if (source)
|
|
1765
|
-
container = source;
|
|
1766
|
-
// ScrollTimeline records progress as a percentage CSSUnitValue
|
|
1806
|
+
const timelineCache = new Map();
|
|
1807
|
+
function scrollTimelineFallback(options) {
|
|
1767
1808
|
const currentTime = { value: 0 };
|
|
1768
1809
|
const cancel = scrollInfo((info) => {
|
|
1769
|
-
currentTime.value = info[axis].progress * 100;
|
|
1770
|
-
},
|
|
1810
|
+
currentTime.value = info[options.axis].progress * 100;
|
|
1811
|
+
}, options);
|
|
1771
1812
|
return { currentTime, cancel };
|
|
1772
1813
|
}
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
// Support legacy source argument. Deprecate later.
|
|
1814
|
+
function getTimeline({ source, container, ...options }) {
|
|
1815
|
+
const { axis } = options;
|
|
1776
1816
|
if (source)
|
|
1777
1817
|
container = source;
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
const
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1818
|
+
const containerCache = timelineCache.get(container) ?? new Map();
|
|
1819
|
+
timelineCache.set(container, containerCache);
|
|
1820
|
+
const targetKey = options.target ?? "self";
|
|
1821
|
+
const targetCache = containerCache.get(targetKey) ?? {};
|
|
1822
|
+
const axisKey = axis + (options.offset ?? []).join(",");
|
|
1823
|
+
if (!targetCache[axisKey]) {
|
|
1824
|
+
targetCache[axisKey] =
|
|
1825
|
+
!options.target && motionDom.supportsScrollTimeline()
|
|
1826
|
+
? new ScrollTimeline({ source: container, axis })
|
|
1827
|
+
: scrollTimelineFallback({ container, ...options });
|
|
1828
|
+
}
|
|
1829
|
+
return targetCache[axis];
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
function attachToAnimation(animation, options) {
|
|
1833
|
+
const timeline = getTimeline(options);
|
|
1834
|
+
return animation.attachTimeline({
|
|
1835
|
+
timeline: options.target ? undefined : timeline,
|
|
1836
|
+
observe: (valueAnimation) => {
|
|
1837
|
+
valueAnimation.pause();
|
|
1838
|
+
return motionDom.observeTimeline((progress) => {
|
|
1839
|
+
valueAnimation.time = valueAnimation.duration * progress;
|
|
1840
|
+
}, timeline);
|
|
1841
|
+
},
|
|
1842
|
+
});
|
|
1788
1843
|
}
|
|
1844
|
+
|
|
1789
1845
|
/**
|
|
1790
1846
|
* If the onScroll function has two arguments, it's expecting
|
|
1791
1847
|
* more specific information about the scroll from scrollInfo.
|
|
@@ -1793,51 +1849,22 @@ function getTimeline({ source, container = document.documentElement, axis = "y",
|
|
|
1793
1849
|
function isOnScrollWithInfo(onScroll) {
|
|
1794
1850
|
return onScroll.length === 2;
|
|
1795
1851
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
* the future we can also offer ViewTimeline support.
|
|
1799
|
-
*/
|
|
1800
|
-
function needsElementTracking(options) {
|
|
1801
|
-
return options && (options.target || options.offset);
|
|
1802
|
-
}
|
|
1803
|
-
function scrollFunction(onScroll, options) {
|
|
1804
|
-
if (isOnScrollWithInfo(onScroll) || needsElementTracking(options)) {
|
|
1852
|
+
function attachToFunction(onScroll, options) {
|
|
1853
|
+
if (isOnScrollWithInfo(onScroll)) {
|
|
1805
1854
|
return scrollInfo((info) => {
|
|
1806
1855
|
onScroll(info[options.axis].progress, info);
|
|
1807
1856
|
}, options);
|
|
1808
1857
|
}
|
|
1809
1858
|
else {
|
|
1810
|
-
return observeTimeline(onScroll, getTimeline(options));
|
|
1811
|
-
}
|
|
1812
|
-
}
|
|
1813
|
-
function scrollAnimation(animation, options) {
|
|
1814
|
-
animation.flatten();
|
|
1815
|
-
if (needsElementTracking(options)) {
|
|
1816
|
-
animation.pause();
|
|
1817
|
-
return scrollInfo((info) => {
|
|
1818
|
-
animation.time = animation.duration * info[options.axis].progress;
|
|
1819
|
-
}, options);
|
|
1820
|
-
}
|
|
1821
|
-
else {
|
|
1822
|
-
const timeline = getTimeline(options);
|
|
1823
|
-
if (animation.attachTimeline) {
|
|
1824
|
-
return animation.attachTimeline(timeline, (valueAnimation) => {
|
|
1825
|
-
valueAnimation.pause();
|
|
1826
|
-
return observeTimeline((progress) => {
|
|
1827
|
-
valueAnimation.time = valueAnimation.duration * progress;
|
|
1828
|
-
}, timeline);
|
|
1829
|
-
});
|
|
1830
|
-
}
|
|
1831
|
-
else {
|
|
1832
|
-
return motionUtils.noop;
|
|
1833
|
-
}
|
|
1859
|
+
return motionDom.observeTimeline(onScroll, getTimeline(options));
|
|
1834
1860
|
}
|
|
1835
1861
|
}
|
|
1836
|
-
|
|
1837
|
-
|
|
1862
|
+
|
|
1863
|
+
function scroll(onScroll, { axis = "y", container = document.documentElement, ...options } = {}) {
|
|
1864
|
+
const optionsWithDefaults = { axis, container, ...options };
|
|
1838
1865
|
return typeof onScroll === "function"
|
|
1839
|
-
?
|
|
1840
|
-
:
|
|
1866
|
+
? attachToFunction(onScroll, optionsWithDefaults)
|
|
1867
|
+
: attachToAnimation(onScroll, optionsWithDefaults);
|
|
1841
1868
|
}
|
|
1842
1869
|
|
|
1843
1870
|
const thresholds = {
|
|
@@ -1880,18 +1907,6 @@ function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount =
|
|
|
1880
1907
|
return () => observer.disconnect();
|
|
1881
1908
|
}
|
|
1882
1909
|
|
|
1883
|
-
function steps(numSteps, direction = "end") {
|
|
1884
|
-
return (progress) => {
|
|
1885
|
-
progress =
|
|
1886
|
-
direction === "end"
|
|
1887
|
-
? Math.min(progress, 0.999)
|
|
1888
|
-
: Math.max(progress, 0.001);
|
|
1889
|
-
const expanded = progress * numSteps;
|
|
1890
|
-
const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
|
|
1891
|
-
return create.clamp(0, 1, rounded / numSteps);
|
|
1892
|
-
};
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
1910
|
function getOriginIndex(from, total) {
|
|
1896
1911
|
if (from === "first") {
|
|
1897
1912
|
return 0;
|
|
@@ -1908,7 +1923,7 @@ function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
|
|
|
1908
1923
|
let delay = duration * distance;
|
|
1909
1924
|
if (ease) {
|
|
1910
1925
|
const maxDelay = total * duration;
|
|
1911
|
-
const easingFunction =
|
|
1926
|
+
const easingFunction = motionUtils.easingDefinitionToFunction(ease);
|
|
1912
1927
|
delay = easingFunction(delay / maxDelay) * maxDelay;
|
|
1913
1928
|
}
|
|
1914
1929
|
return startDelay + delay;
|
|
@@ -2064,7 +2079,7 @@ function useSpring(source, config = {}) {
|
|
|
2064
2079
|
const latestSetter = React.useRef(motionUtils.noop);
|
|
2065
2080
|
const startAnimation = () => {
|
|
2066
2081
|
stopAnimation();
|
|
2067
|
-
activeSpringAnimation.current =
|
|
2082
|
+
activeSpringAnimation.current = new motionDom.JSAnimation({
|
|
2068
2083
|
keyframes: [asNumber(value.get()), asNumber(latestValue.current)],
|
|
2069
2084
|
velocity: value.getVelocity(),
|
|
2070
2085
|
type: "spring",
|
|
@@ -2156,10 +2171,10 @@ function useVelocity(value) {
|
|
|
2156
2171
|
}
|
|
2157
2172
|
|
|
2158
2173
|
function getWillChangeName(name) {
|
|
2159
|
-
if (
|
|
2174
|
+
if (motionDom.transformProps.has(name)) {
|
|
2160
2175
|
return "transform";
|
|
2161
2176
|
}
|
|
2162
|
-
else if (
|
|
2177
|
+
else if (motionDom.acceleratedValues.has(name)) {
|
|
2163
2178
|
return create.camelToDash(name);
|
|
2164
2179
|
}
|
|
2165
2180
|
}
|
|
@@ -2570,7 +2585,7 @@ function useCycle(...items) {
|
|
|
2570
2585
|
const runCycle = React.useCallback((next) => {
|
|
2571
2586
|
index.current =
|
|
2572
2587
|
typeof next !== "number"
|
|
2573
|
-
? wrap(0, items.length, index.current + 1)
|
|
2588
|
+
? motionUtils.wrap(0, items.length, index.current + 1)
|
|
2574
2589
|
: next;
|
|
2575
2590
|
setItem(items[index.current]);
|
|
2576
2591
|
},
|
|
@@ -2618,12 +2633,12 @@ function useInstantTransition() {
|
|
|
2618
2633
|
*/
|
|
2619
2634
|
if (forcedRenderCount !== unlockOnFrameRef.current)
|
|
2620
2635
|
return;
|
|
2621
|
-
|
|
2636
|
+
motionUtils.MotionGlobalConfig.instantAnimations = false;
|
|
2622
2637
|
}));
|
|
2623
2638
|
}, [forcedRenderCount]);
|
|
2624
2639
|
return (callback) => {
|
|
2625
2640
|
startInstantLayoutTransition(() => {
|
|
2626
|
-
|
|
2641
|
+
motionUtils.MotionGlobalConfig.instantAnimations = true;
|
|
2627
2642
|
forceUpdate();
|
|
2628
2643
|
callback();
|
|
2629
2644
|
unlockOnFrameRef.current = forcedRenderCount + 1;
|
|
@@ -2631,14 +2646,14 @@ function useInstantTransition() {
|
|
|
2631
2646
|
};
|
|
2632
2647
|
}
|
|
2633
2648
|
function disableInstantTransitions() {
|
|
2634
|
-
|
|
2649
|
+
motionUtils.MotionGlobalConfig.instantAnimations = false;
|
|
2635
2650
|
}
|
|
2636
2651
|
|
|
2637
2652
|
const appearAnimationStore = new Map();
|
|
2638
2653
|
const appearComplete = new Map();
|
|
2639
2654
|
|
|
2640
2655
|
const appearStoreId = (elementId, valueName) => {
|
|
2641
|
-
const key =
|
|
2656
|
+
const key = motionDom.transformProps.has(valueName) ? "transform" : valueName;
|
|
2642
2657
|
return `${elementId}: ${key}`;
|
|
2643
2658
|
};
|
|
2644
2659
|
|
|
@@ -2947,7 +2962,6 @@ function useInvertedScale(scale) {
|
|
|
2947
2962
|
return { scaleX, scaleY };
|
|
2948
2963
|
}
|
|
2949
2964
|
|
|
2950
|
-
exports.AcceleratedAnimation = create.AcceleratedAnimation;
|
|
2951
2965
|
exports.FlatTree = create.FlatTree;
|
|
2952
2966
|
exports.LayoutGroupContext = create.LayoutGroupContext;
|
|
2953
2967
|
exports.MotionConfigContext = create.MotionConfigContext;
|
|
@@ -2958,111 +2972,30 @@ exports.VisualElement = create.VisualElement;
|
|
|
2958
2972
|
exports.addPointerEvent = create.addPointerEvent;
|
|
2959
2973
|
exports.addPointerInfo = create.addPointerInfo;
|
|
2960
2974
|
exports.addScaleCorrector = create.addScaleCorrector;
|
|
2961
|
-
exports.animateValue = create.animateValue;
|
|
2962
2975
|
exports.animateVisualElement = create.animateVisualElement;
|
|
2963
2976
|
exports.animations = create.animations;
|
|
2964
|
-
exports.anticipate = create.anticipate;
|
|
2965
|
-
exports.backIn = create.backIn;
|
|
2966
|
-
exports.backInOut = create.backInOut;
|
|
2967
|
-
exports.backOut = create.backOut;
|
|
2968
2977
|
exports.buildTransform = create.buildTransform;
|
|
2969
2978
|
exports.calcLength = create.calcLength;
|
|
2970
|
-
exports.circIn = create.circIn;
|
|
2971
|
-
exports.circInOut = create.circInOut;
|
|
2972
|
-
exports.circOut = create.circOut;
|
|
2973
|
-
exports.clamp = create.clamp;
|
|
2974
|
-
exports.color = create.color;
|
|
2975
|
-
exports.complex = create.complex;
|
|
2976
2979
|
exports.createBox = create.createBox;
|
|
2977
2980
|
exports.createRendererMotionComponent = create.createRendererMotionComponent;
|
|
2978
|
-
exports.cubicBezier = create.cubicBezier;
|
|
2979
2981
|
exports.delay = create.delay;
|
|
2980
2982
|
exports.distance = create.distance;
|
|
2981
2983
|
exports.distance2D = create.distance2D;
|
|
2982
|
-
exports.easeIn = create.easeIn;
|
|
2983
|
-
exports.easeInOut = create.easeInOut;
|
|
2984
|
-
exports.easeOut = create.easeOut;
|
|
2985
2984
|
exports.filterProps = create.filterProps;
|
|
2986
|
-
exports.findSpring = create.findSpring;
|
|
2987
|
-
exports.inertia = create.inertia;
|
|
2988
|
-
exports.interpolate = create.interpolate;
|
|
2989
2985
|
exports.isBrowser = create.isBrowser;
|
|
2990
2986
|
exports.isMotionValue = create.isMotionValue;
|
|
2991
2987
|
exports.isValidMotionProp = create.isValidMotionProp;
|
|
2992
|
-
exports.keyframes = create.keyframes;
|
|
2993
2988
|
exports.makeUseVisualState = create.makeUseVisualState;
|
|
2994
|
-
exports.mirrorEasing = create.mirrorEasing;
|
|
2995
|
-
exports.mix = create.mix;
|
|
2996
2989
|
exports.optimizedAppearDataAttribute = create.optimizedAppearDataAttribute;
|
|
2997
|
-
exports.pipe = create.pipe;
|
|
2998
|
-
exports.px = create.px;
|
|
2999
2990
|
exports.resolveMotionValue = create.resolveMotionValue;
|
|
3000
|
-
exports.reverseEasing = create.reverseEasing;
|
|
3001
|
-
exports.spring = create.spring;
|
|
3002
2991
|
exports.useIsPresent = create.useIsPresent;
|
|
3003
2992
|
exports.useIsomorphicLayoutEffect = create.useIsomorphicLayoutEffect;
|
|
3004
2993
|
exports.usePresence = create.usePresence;
|
|
3005
2994
|
exports.visualElementStore = create.visualElementStore;
|
|
3006
|
-
Object.defineProperty(exports, "MotionValue", {
|
|
3007
|
-
enumerable: true,
|
|
3008
|
-
get: function () { return motionDom.MotionValue; }
|
|
3009
|
-
});
|
|
3010
|
-
Object.defineProperty(exports, "cancelFrame", {
|
|
3011
|
-
enumerable: true,
|
|
3012
|
-
get: function () { return motionDom.cancelFrame; }
|
|
3013
|
-
});
|
|
3014
|
-
Object.defineProperty(exports, "cancelSync", {
|
|
3015
|
-
enumerable: true,
|
|
3016
|
-
get: function () { return motionDom.cancelSync; }
|
|
3017
|
-
});
|
|
3018
|
-
Object.defineProperty(exports, "frame", {
|
|
3019
|
-
enumerable: true,
|
|
3020
|
-
get: function () { return motionDom.frame; }
|
|
3021
|
-
});
|
|
3022
|
-
Object.defineProperty(exports, "frameData", {
|
|
3023
|
-
enumerable: true,
|
|
3024
|
-
get: function () { return motionDom.frameData; }
|
|
3025
|
-
});
|
|
3026
|
-
Object.defineProperty(exports, "hover", {
|
|
3027
|
-
enumerable: true,
|
|
3028
|
-
get: function () { return motionDom.hover; }
|
|
3029
|
-
});
|
|
3030
|
-
Object.defineProperty(exports, "isDragActive", {
|
|
3031
|
-
enumerable: true,
|
|
3032
|
-
get: function () { return motionDom.isDragActive; }
|
|
3033
|
-
});
|
|
3034
|
-
Object.defineProperty(exports, "motionValue", {
|
|
3035
|
-
enumerable: true,
|
|
3036
|
-
get: function () { return motionDom.motionValue; }
|
|
3037
|
-
});
|
|
3038
|
-
Object.defineProperty(exports, "press", {
|
|
3039
|
-
enumerable: true,
|
|
3040
|
-
get: function () { return motionDom.press; }
|
|
3041
|
-
});
|
|
3042
|
-
Object.defineProperty(exports, "sync", {
|
|
3043
|
-
enumerable: true,
|
|
3044
|
-
get: function () { return motionDom.sync; }
|
|
3045
|
-
});
|
|
3046
|
-
Object.defineProperty(exports, "time", {
|
|
3047
|
-
enumerable: true,
|
|
3048
|
-
get: function () { return motionDom.time; }
|
|
3049
|
-
});
|
|
3050
2995
|
Object.defineProperty(exports, "MotionGlobalConfig", {
|
|
3051
2996
|
enumerable: true,
|
|
3052
2997
|
get: function () { return motionUtils.MotionGlobalConfig; }
|
|
3053
2998
|
});
|
|
3054
|
-
Object.defineProperty(exports, "invariant", {
|
|
3055
|
-
enumerable: true,
|
|
3056
|
-
get: function () { return motionUtils.invariant; }
|
|
3057
|
-
});
|
|
3058
|
-
Object.defineProperty(exports, "noop", {
|
|
3059
|
-
enumerable: true,
|
|
3060
|
-
get: function () { return motionUtils.noop; }
|
|
3061
|
-
});
|
|
3062
|
-
Object.defineProperty(exports, "progress", {
|
|
3063
|
-
enumerable: true,
|
|
3064
|
-
get: function () { return motionUtils.progress; }
|
|
3065
|
-
});
|
|
3066
2999
|
exports.AnimatePresence = AnimatePresence;
|
|
3067
3000
|
exports.AnimateSharedLayout = AnimateSharedLayout;
|
|
3068
3001
|
exports.DeprecatedLayoutGroupContext = DeprecatedLayoutGroupContext;
|
|
@@ -3088,7 +3021,6 @@ exports.scroll = scroll;
|
|
|
3088
3021
|
exports.scrollInfo = scrollInfo;
|
|
3089
3022
|
exports.stagger = stagger;
|
|
3090
3023
|
exports.startOptimizedAppearAnimation = startOptimizedAppearAnimation;
|
|
3091
|
-
exports.steps = steps;
|
|
3092
3024
|
exports.transform = transform;
|
|
3093
3025
|
exports.unwrapMotionComponent = unwrapMotionComponent;
|
|
3094
3026
|
exports.useAnimate = useAnimate;
|
|
@@ -3121,4 +3053,15 @@ exports.useUnmountEffect = useUnmountEffect;
|
|
|
3121
3053
|
exports.useVelocity = useVelocity;
|
|
3122
3054
|
exports.useViewportScroll = useViewportScroll;
|
|
3123
3055
|
exports.useWillChange = useWillChange;
|
|
3124
|
-
|
|
3056
|
+
Object.keys(motionDom).forEach(function (k) {
|
|
3057
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
3058
|
+
enumerable: true,
|
|
3059
|
+
get: function () { return motionDom[k]; }
|
|
3060
|
+
});
|
|
3061
|
+
});
|
|
3062
|
+
Object.keys(motionUtils).forEach(function (k) {
|
|
3063
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
3064
|
+
enumerable: true,
|
|
3065
|
+
get: function () { return motionUtils[k]; }
|
|
3066
|
+
});
|
|
3067
|
+
});
|