motion-dom 14.5.0 → 14.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +144 -55
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/NativeAnimation.mjs +10 -4
- package/dist/es/animation/NativeAnimation.mjs.map +1 -1
- package/dist/es/animation/generators/spring.mjs +11 -9
- package/dist/es/animation/generators/spring.mjs.map +1 -1
- package/dist/es/animation/keyframes/utils/unit-conversion.mjs +8 -7
- package/dist/es/animation/keyframes/utils/unit-conversion.mjs.map +1 -1
- package/dist/es/animation/optimized-appear/data-id.mjs +1 -3
- package/dist/es/animation/optimized-appear/data-id.mjs.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +8 -2
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/frameloop/process-frame.mjs +42 -0
- package/dist/es/frameloop/process-frame.mjs.map +1 -0
- package/dist/es/frameloop/render-step.mjs +15 -1
- package/dist/es/frameloop/render-step.mjs.map +1 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +16 -6
- package/dist/es/gestures/drag/VisualElementDragControls.mjs.map +1 -1
- package/dist/es/index.mjs +3 -1
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/projection/node/DocumentProjectionNode.mjs +8 -3
- package/dist/es/projection/node/DocumentProjectionNode.mjs.map +1 -1
- package/dist/es/projection/node/HTMLProjectionNode.mjs +4 -5
- package/dist/es/projection/node/HTMLProjectionNode.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +21 -12
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/projection/node/root.mjs +6 -0
- package/dist/es/projection/node/root.mjs.map +1 -0
- package/dist/es/projection/styles/default-scale-correctors.mjs +3 -4
- package/dist/es/projection/styles/default-scale-correctors.mjs.map +1 -1
- package/dist/es/render/utils/animation-state.mjs +1 -2
- package/dist/es/render/utils/animation-state.mjs.map +1 -1
- package/dist/es/render/utils/variant-props.mjs +1 -1
- package/dist/es/render/utils/variant-props.mjs.map +1 -1
- package/dist/index.d.ts +44 -14
- package/dist/motion-dom.dev.js +144 -55
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-motion-value.js +1 -1
- package/dist/size-rollup-motion-value.js.map +1 -1
- package/dist/size-rollup-style-effect.js +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -621,6 +621,11 @@ function createRenderStep(runNextFrame) {
|
|
|
621
621
|
*/
|
|
622
622
|
let isProcessing = false;
|
|
623
623
|
let flushNextFrame = false;
|
|
624
|
+
/**
|
|
625
|
+
* The callback currently running. If it schedules itself with `immediate`
|
|
626
|
+
* it's left in place, so as before it doesn't run again this step.
|
|
627
|
+
*/
|
|
628
|
+
let running;
|
|
624
629
|
/**
|
|
625
630
|
* A set of processes which were marked keepAlive when scheduled.
|
|
626
631
|
* A keepAlive process is always also held by a frame queue until
|
|
@@ -638,7 +643,7 @@ function createRenderStep(runNextFrame) {
|
|
|
638
643
|
nextFrame.add(callback);
|
|
639
644
|
runNextFrame();
|
|
640
645
|
}
|
|
641
|
-
callback(latestFrameData);
|
|
646
|
+
(running = callback)(latestFrameData);
|
|
642
647
|
}
|
|
643
648
|
const step = {
|
|
644
649
|
/**
|
|
@@ -649,6 +654,14 @@ function createRenderStep(runNextFrame) {
|
|
|
649
654
|
const queue = addToCurrentFrame ? thisFrame : nextFrame;
|
|
650
655
|
if (keepAlive)
|
|
651
656
|
toKeepAlive.add(callback);
|
|
657
|
+
/**
|
|
658
|
+
* A callback scheduled with `immediate` during processing may
|
|
659
|
+
* already have run this step (for instance, a value it reads was
|
|
660
|
+
* changed by a later callback). Re-adding moves it to the end of
|
|
661
|
+
* the queue, so it runs again. The running callback is excluded,
|
|
662
|
+
* so one that re-schedules itself can't loop forever.
|
|
663
|
+
*/
|
|
664
|
+
addToCurrentFrame && callback !== running && queue.delete(callback);
|
|
652
665
|
queue.add(callback);
|
|
653
666
|
return callback;
|
|
654
667
|
},
|
|
@@ -683,6 +696,7 @@ function createRenderStep(runNextFrame) {
|
|
|
683
696
|
// Clear the frame so no callbacks remain. This is to avoid
|
|
684
697
|
// memory leaks should this render step not run for a while.
|
|
685
698
|
thisFrame.clear();
|
|
699
|
+
running = undefined;
|
|
686
700
|
isProcessing = false;
|
|
687
701
|
if (flushNextFrame) {
|
|
688
702
|
flushNextFrame = false;
|
|
@@ -1029,7 +1043,7 @@ function getSpringOptions(options) {
|
|
|
1029
1043
|
}
|
|
1030
1044
|
return springOptions;
|
|
1031
1045
|
}
|
|
1032
|
-
function
|
|
1046
|
+
function springGenerator(optionsOrVisualDuration = springDefaults.visualDuration, bounce = springDefaults.bounce) {
|
|
1033
1047
|
const options = typeof optionsOrVisualDuration !== "object"
|
|
1034
1048
|
? {
|
|
1035
1049
|
visualDuration: optionsOrVisualDuration,
|
|
@@ -1214,13 +1228,15 @@ function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce
|
|
|
1214
1228
|
};
|
|
1215
1229
|
return generator;
|
|
1216
1230
|
}
|
|
1217
|
-
spring
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1231
|
+
const spring = /* @__PURE__ */ Object.assign(springGenerator, {
|
|
1232
|
+
applyToOptions: (options) => {
|
|
1233
|
+
const generatorOptions = createGeneratorEasing(options, 100, springGenerator);
|
|
1234
|
+
options.ease = generatorOptions.ease;
|
|
1235
|
+
options.duration = motionUtils.secondsToMilliseconds(generatorOptions.duration);
|
|
1236
|
+
options.type = "keyframes";
|
|
1237
|
+
return options;
|
|
1238
|
+
},
|
|
1239
|
+
});
|
|
1224
1240
|
|
|
1225
1241
|
function inertia({ keyframes, velocity = 0.0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed, }) {
|
|
1226
1242
|
const origin = keyframes[0];
|
|
@@ -2303,7 +2319,7 @@ const transformProps = /*@__PURE__*/ (() => new Set([...transformPropOrder, "pat
|
|
|
2303
2319
|
|
|
2304
2320
|
const isNumOrPxType = (v) => v === number || v === px;
|
|
2305
2321
|
const transformKeys = new Set(["x", "y", "z"]);
|
|
2306
|
-
const nonTranslationalTransformKeys = transformPropOrder.filter((key) => !transformKeys.has(key));
|
|
2322
|
+
const nonTranslationalTransformKeys = /* @__PURE__ */ transformPropOrder.filter((key) => !transformKeys.has(key));
|
|
2307
2323
|
/**
|
|
2308
2324
|
* Reset any bounding box-changing transforms so the element can be
|
|
2309
2325
|
* measured. Returns the values to restore. Values already at their
|
|
@@ -2345,6 +2361,8 @@ function measureDimension(computed, measureBox, axis, paddingStart, paddingEnd,
|
|
|
2345
2361
|
? size
|
|
2346
2362
|
: size - parseFloat(paddingStart) - parseFloat(paddingEnd);
|
|
2347
2363
|
}
|
|
2364
|
+
const transformX = ({ transform }) => parseValueFromTransform(transform, "x");
|
|
2365
|
+
const transformY = ({ transform }) => parseValueFromTransform(transform, "y");
|
|
2348
2366
|
const positionalValues = {
|
|
2349
2367
|
// Dimensions
|
|
2350
2368
|
width: ({ width, paddingLeft = "0", paddingRight = "0", boxSizing }, measureBox) => measureDimension(width, measureBox, "x", paddingLeft, paddingRight, boxSizing),
|
|
@@ -2359,13 +2377,12 @@ const positionalValues = {
|
|
|
2359
2377
|
const { x } = measureBox();
|
|
2360
2378
|
return parseFloat(left) + (x.max - x.min);
|
|
2361
2379
|
},
|
|
2362
|
-
// Transform
|
|
2363
|
-
x:
|
|
2364
|
-
y:
|
|
2380
|
+
// Transform, including translate longform names
|
|
2381
|
+
x: transformX,
|
|
2382
|
+
y: transformY,
|
|
2383
|
+
translateX: transformX,
|
|
2384
|
+
translateY: transformY,
|
|
2365
2385
|
};
|
|
2366
|
-
// Alias translate longform names
|
|
2367
|
-
positionalValues.translateX = positionalValues.x;
|
|
2368
|
-
positionalValues.translateY = positionalValues.y;
|
|
2369
2386
|
|
|
2370
2387
|
const toResolve = new Set();
|
|
2371
2388
|
let isScheduled = false;
|
|
@@ -2719,18 +2736,24 @@ class NativeAnimation extends WithPromise {
|
|
|
2719
2736
|
if (this.isStopped)
|
|
2720
2737
|
return;
|
|
2721
2738
|
this.isStopped = true;
|
|
2722
|
-
|
|
2723
|
-
|
|
2739
|
+
/**
|
|
2740
|
+
* Before its finish event, a finished animation (an instant one is
|
|
2741
|
+
* as soon as it starts) is still showing its end, so it's stopped
|
|
2742
|
+
* like a running one. Otherwise that event would apply its end
|
|
2743
|
+
* over whatever animates the value next.
|
|
2744
|
+
*/
|
|
2745
|
+
if (this.state === "idle" || this.finishedTime !== null)
|
|
2724
2746
|
return;
|
|
2725
|
-
}
|
|
2726
2747
|
if (this.updateMotionValue) {
|
|
2727
2748
|
this.updateMotionValue();
|
|
2728
2749
|
}
|
|
2729
2750
|
else {
|
|
2730
2751
|
this.commitStyles();
|
|
2731
2752
|
}
|
|
2732
|
-
if (!this.isPseudoElement)
|
|
2753
|
+
if (!this.isPseudoElement) {
|
|
2754
|
+
this.animation.onfinish = null;
|
|
2733
2755
|
this.cancel();
|
|
2756
|
+
}
|
|
2734
2757
|
}
|
|
2735
2758
|
/**
|
|
2736
2759
|
* WAAPI doesn't natively have any interruption capabilities.
|
|
@@ -3039,7 +3062,13 @@ const colorProperties = new Set([
|
|
|
3039
3062
|
"borderBottomColor",
|
|
3040
3063
|
"borderLeftColor",
|
|
3041
3064
|
]);
|
|
3042
|
-
|
|
3065
|
+
/**
|
|
3066
|
+
* WAAPI runs on the browser's clock, so on a manual clock every animation
|
|
3067
|
+
* runs in JS where processFrame can drive it. Set the flag before starting
|
|
3068
|
+
* animations: running WAAPI animations stay on the browser's clock.
|
|
3069
|
+
*/
|
|
3070
|
+
const supportsWaapi = () => !motionUtils.MotionGlobalConfig.useManualTiming &&
|
|
3071
|
+
Object.hasOwnProperty.call(Element.prototype, "animate");
|
|
3043
3072
|
function supportsBrowserAnimation(options) {
|
|
3044
3073
|
const { motionValue, name, repeatDelay, repeatType, damping, type, keyframes, } = options;
|
|
3045
3074
|
/**
|
|
@@ -5230,12 +5259,8 @@ function addValueToWillChange(visualElement, key) {
|
|
|
5230
5259
|
}
|
|
5231
5260
|
}
|
|
5232
5261
|
|
|
5233
|
-
function camelToDash(str) {
|
|
5234
|
-
return str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
|
|
5235
|
-
}
|
|
5236
|
-
|
|
5237
5262
|
const optimizedAppearDataId = "framerAppearId";
|
|
5238
|
-
const optimizedAppearDataAttribute = "data-"
|
|
5263
|
+
const optimizedAppearDataAttribute = "data-framer-appear-id";
|
|
5239
5264
|
|
|
5240
5265
|
function getOptimisedAppearId(visualElement) {
|
|
5241
5266
|
return visualElement.props[optimizedAppearDataAttribute];
|
|
@@ -6163,6 +6188,10 @@ const styleSubjectEffect = /*@__PURE__*/ createEffect(addStyleValue, {
|
|
|
6163
6188
|
const styleEffect =
|
|
6164
6189
|
/*@__PURE__*/ createSelectorEffect(styleSubjectEffect);
|
|
6165
6190
|
|
|
6191
|
+
function camelToDash(str) {
|
|
6192
|
+
return str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
|
|
6193
|
+
}
|
|
6194
|
+
|
|
6166
6195
|
function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
6167
6196
|
const { style, vars, transformOrigin } = state;
|
|
6168
6197
|
// Track whether we encounter any transform or transformOrigin values.
|
|
@@ -6738,6 +6767,41 @@ const propEffect = /*@__PURE__*/ createEffect((subject, state, key, value) => {
|
|
|
6738
6767
|
const { schedule: microtask, cancel: cancelMicrotask } =
|
|
6739
6768
|
/* @__PURE__ */ createRenderBatcher(queueMicrotask, false);
|
|
6740
6769
|
|
|
6770
|
+
/**
|
|
6771
|
+
* Process a frame now, for driving Motion from a loop other than
|
|
6772
|
+
* window.requestAnimationFrame, like an XRSession's during an immersive
|
|
6773
|
+
* WebXR session. Wherever window.requestAnimationFrame does fire, Motion
|
|
6774
|
+
* keeps processing frames from it too.
|
|
6775
|
+
*
|
|
6776
|
+
* `timestamp` defaults to now. For a timeline you control, set
|
|
6777
|
+
* `MotionGlobalConfig.useManualTiming = true` and pass each frame's time in
|
|
6778
|
+
* milliseconds.
|
|
6779
|
+
*
|
|
6780
|
+
* Animations Motion hands to the browser (WAAPI), like `opacity` or
|
|
6781
|
+
* `transform` on an HTML or SVG element, follow the browser's clock. With
|
|
6782
|
+
* `useManualTiming` on, Motion runs those in JS instead, except for
|
|
6783
|
+
* `motion/mini`, view transitions and optimized appear animations, and
|
|
6784
|
+
* colours only the browser can mix, like `oklch()`, which jump to their end.
|
|
6785
|
+
*
|
|
6786
|
+
* Ignored when called inside a frame.
|
|
6787
|
+
*/
|
|
6788
|
+
const processFrame = (timestamp = time.now()) => {
|
|
6789
|
+
if (frameData.isProcessing)
|
|
6790
|
+
return;
|
|
6791
|
+
const delta = timestamp - frameData.timestamp;
|
|
6792
|
+
// Clamp like the requestAnimationFrame loop, unless the timeline is ours
|
|
6793
|
+
frameData.delta = motionUtils.MotionGlobalConfig.useManualTiming
|
|
6794
|
+
? delta
|
|
6795
|
+
: Math.max(Math.min(delta, 40), 1);
|
|
6796
|
+
time.set((frameData.timestamp = timestamp));
|
|
6797
|
+
frameData.isProcessing = true;
|
|
6798
|
+
// frameSteps' keys are in stepsOrder
|
|
6799
|
+
for (const step in frameSteps) {
|
|
6800
|
+
frameSteps[step].process(frameData);
|
|
6801
|
+
}
|
|
6802
|
+
frameData.isProcessing = false;
|
|
6803
|
+
};
|
|
6804
|
+
|
|
6741
6805
|
function animateSingleValue(value, keyframes, options) {
|
|
6742
6806
|
const motionValue$1 = isMotionValue(value) ? value : motionValue(value);
|
|
6743
6807
|
motionValue$1.start(animateMotionValue("", motionValue$1, keyframes, options));
|
|
@@ -7204,10 +7268,9 @@ const correctBoxShadow = {
|
|
|
7204
7268
|
};
|
|
7205
7269
|
|
|
7206
7270
|
const defaultScaleCorrectors = {
|
|
7207
|
-
borderRadius: {
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
},
|
|
7271
|
+
borderRadius: /* @__PURE__ */ Object.assign({}, correctBorderRadius, {
|
|
7272
|
+
applyTo: /* @__PURE__ */ cornerRadiusProps.slice(),
|
|
7273
|
+
}),
|
|
7211
7274
|
borderTopLeftRadius: correctBorderRadius,
|
|
7212
7275
|
borderTopRightRadius: correctBorderRadius,
|
|
7213
7276
|
borderBottomLeftRadius: correctBorderRadius,
|
|
@@ -7312,14 +7375,6 @@ const globalProjectionState = {
|
|
|
7312
7375
|
hasEverUpdated: false,
|
|
7313
7376
|
};
|
|
7314
7377
|
|
|
7315
|
-
/**
|
|
7316
|
-
* Correctors registered via addScaleCorrector before projection loaded
|
|
7317
|
-
* (e.g. with an async LazyMotion bundle) take precedence over the defaults.
|
|
7318
|
-
*/
|
|
7319
|
-
Object.assign(scaleCorrectors, {
|
|
7320
|
-
...defaultScaleCorrectors,
|
|
7321
|
-
...scaleCorrectors,
|
|
7322
|
-
});
|
|
7323
7378
|
const metrics = {
|
|
7324
7379
|
nodes: 0,
|
|
7325
7380
|
calculatedTargetDeltas: 0,
|
|
@@ -7362,6 +7417,16 @@ function cancelTreeOptimisedTransformAnimations(projectionNode) {
|
|
|
7362
7417
|
}
|
|
7363
7418
|
}
|
|
7364
7419
|
function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
|
|
7420
|
+
/**
|
|
7421
|
+
* Correctors registered via addScaleCorrector before projection loaded
|
|
7422
|
+
* (e.g. with an async LazyMotion bundle) take precedence over the defaults.
|
|
7423
|
+
* Applied here rather than at module scope so bundlers can drop projection
|
|
7424
|
+
* when it's unused.
|
|
7425
|
+
*/
|
|
7426
|
+
Object.assign(scaleCorrectors, {
|
|
7427
|
+
...defaultScaleCorrectors,
|
|
7428
|
+
...scaleCorrectors,
|
|
7429
|
+
});
|
|
7365
7430
|
return class ProjectionNode {
|
|
7366
7431
|
constructor(latestValues = {}, parent = defaultParent?.()) {
|
|
7367
7432
|
/**
|
|
@@ -8018,7 +8083,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8018
8083
|
}
|
|
8019
8084
|
return boxWithoutScroll;
|
|
8020
8085
|
}
|
|
8021
|
-
applyTransform(box, transformOnly = false, output) {
|
|
8086
|
+
applyTransform(box, transformOnly = false, output, skipOwnTransform) {
|
|
8022
8087
|
const withTransforms = output || createBox();
|
|
8023
8088
|
copyBoxInto(withTransforms, box);
|
|
8024
8089
|
for (let i = 0; i < this.path.length; i++) {
|
|
@@ -8034,7 +8099,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8034
8099
|
continue;
|
|
8035
8100
|
transformBox(withTransforms, node.latestValues, node.layout?.layoutBox);
|
|
8036
8101
|
}
|
|
8037
|
-
if (hasTransform(this.latestValues)) {
|
|
8102
|
+
if (!skipOwnTransform && hasTransform(this.latestValues)) {
|
|
8038
8103
|
transformBox(withTransforms, this.latestValues, this.layout?.layoutBox);
|
|
8039
8104
|
}
|
|
8040
8105
|
return withTransforms;
|
|
@@ -8169,7 +8234,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8169
8234
|
}
|
|
8170
8235
|
else if (this.targetDelta) {
|
|
8171
8236
|
if (Boolean(this.resumingFrom)) {
|
|
8172
|
-
|
|
8237
|
+
/**
|
|
8238
|
+
* Own transforms are applied later, in applyTransformsToTarget,
|
|
8239
|
+
* so only apply ancestor transforms here or they'd be doubled.
|
|
8240
|
+
*/
|
|
8241
|
+
this.applyTransform(this.layout.layoutBox, false, this.target, true);
|
|
8173
8242
|
}
|
|
8174
8243
|
else {
|
|
8175
8244
|
copyBoxInto(this.target, this.layout.layoutBox);
|
|
@@ -8938,10 +9007,13 @@ function clearIsLayoutDirty(node) {
|
|
|
8938
9007
|
* A dragged node doesn't layout animate, so it jumps to its new layout. Shift
|
|
8939
9008
|
* its descendants' snapshots by the same amount, so they only animate layout
|
|
8940
9009
|
* changes relative to it, rather than lagging behind.
|
|
9010
|
+
*
|
|
9011
|
+
* If its drag ended since the snapshot (e.g. drag disabled from onDrag), it
|
|
9012
|
+
* layout animates again, so its descendants mustn't follow its jump.
|
|
8941
9013
|
*/
|
|
8942
9014
|
function followDraggedAncestor(node) {
|
|
8943
9015
|
const { snapshot, dragAncestor } = node;
|
|
8944
|
-
const to = dragAncestor?.layout;
|
|
9016
|
+
const to = dragAncestor?.isAnimationBlocked && dragAncestor.layout;
|
|
8945
9017
|
if (!snapshot || !to || node.resumeFrom || node.isAnimationBlocked)
|
|
8946
9018
|
return;
|
|
8947
9019
|
const from = dragAncestor.dragSnapshot;
|
|
@@ -9055,11 +9127,16 @@ function addDomEvent(target, eventName, handler, options = { passive: true }) {
|
|
|
9055
9127
|
return () => target.removeEventListener(eventName, handler, options);
|
|
9056
9128
|
}
|
|
9057
9129
|
|
|
9058
|
-
const DocumentProjectionNode =
|
|
9130
|
+
const DocumentProjectionNode =
|
|
9131
|
+
/* @__PURE__ */ createProjectionNode({
|
|
9059
9132
|
attachResizeListener: (ref, notify) => addDomEvent(ref, "resize", notify),
|
|
9060
9133
|
measureScroll: () => ({
|
|
9061
|
-
x: document.documentElement.scrollLeft ||
|
|
9062
|
-
|
|
9134
|
+
x: document.documentElement.scrollLeft ||
|
|
9135
|
+
document.body?.scrollLeft ||
|
|
9136
|
+
0,
|
|
9137
|
+
y: document.documentElement.scrollTop ||
|
|
9138
|
+
document.body?.scrollTop ||
|
|
9139
|
+
0,
|
|
9063
9140
|
}),
|
|
9064
9141
|
checkIsScrollRoot: () => true,
|
|
9065
9142
|
});
|
|
@@ -9067,7 +9144,9 @@ const DocumentProjectionNode = createProjectionNode({
|
|
|
9067
9144
|
const rootProjectionNode = {
|
|
9068
9145
|
current: undefined,
|
|
9069
9146
|
};
|
|
9070
|
-
|
|
9147
|
+
|
|
9148
|
+
const HTMLProjectionNode =
|
|
9149
|
+
/* @__PURE__ */ createProjectionNode({
|
|
9071
9150
|
measureScroll: (instance) => ({
|
|
9072
9151
|
x: instance.scrollLeft,
|
|
9073
9152
|
y: instance.scrollTop,
|
|
@@ -9111,7 +9190,7 @@ const variantPriorityOrder = [
|
|
|
9111
9190
|
"whileDrag",
|
|
9112
9191
|
"exit",
|
|
9113
9192
|
];
|
|
9114
|
-
const variantProps = ["initial"
|
|
9193
|
+
const variantProps = /* @__PURE__ */ ["initial"].concat(variantPriorityOrder);
|
|
9115
9194
|
|
|
9116
9195
|
function isControllingVariants(props) {
|
|
9117
9196
|
if (isAnimationControls(props.animate))
|
|
@@ -10957,7 +11036,11 @@ class VisualElementDragControls {
|
|
|
10957
11036
|
element: this.visualElement.current,
|
|
10958
11037
|
});
|
|
10959
11038
|
}
|
|
10960
|
-
|
|
11039
|
+
/**
|
|
11040
|
+
* @param dragAxes - The axes to animate on release, if not the `drag`
|
|
11041
|
+
* prop's, e.g. when drag was disabled mid-gesture.
|
|
11042
|
+
*/
|
|
11043
|
+
stop(event, panInfo, dragAxes) {
|
|
10961
11044
|
const finalEvent = event || this.latestPointerEvent;
|
|
10962
11045
|
const finalPanInfo = panInfo || this.latestPanInfo;
|
|
10963
11046
|
const isDragging = this.isDragging;
|
|
@@ -10965,7 +11048,7 @@ class VisualElementDragControls {
|
|
|
10965
11048
|
if (!isDragging || !finalPanInfo || !finalEvent)
|
|
10966
11049
|
return;
|
|
10967
11050
|
const { velocity } = finalPanInfo;
|
|
10968
|
-
this.startAnimation(velocity);
|
|
11051
|
+
this.startAnimation(velocity, dragAxes);
|
|
10969
11052
|
const { onDragEnd } = this.getProps();
|
|
10970
11053
|
if (onDragEnd) {
|
|
10971
11054
|
frame.postRender(() => onDragEnd(finalEvent, finalPanInfo));
|
|
@@ -11086,11 +11169,11 @@ class VisualElementDragControls {
|
|
|
11086
11169
|
}
|
|
11087
11170
|
return measuredConstraints;
|
|
11088
11171
|
}
|
|
11089
|
-
startAnimation(velocity) {
|
|
11172
|
+
startAnimation(velocity, dragAxes) {
|
|
11090
11173
|
const { drag, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd, } = this.getProps();
|
|
11091
11174
|
const constraints = this.constraints || {};
|
|
11092
11175
|
const momentumAnimations = eachAxis((axis) => {
|
|
11093
|
-
if (!shouldDrag(axis, drag, this.currentDirection)) {
|
|
11176
|
+
if (!shouldDrag(axis, dragAxes || drag, this.currentDirection)) {
|
|
11094
11177
|
return;
|
|
11095
11178
|
}
|
|
11096
11179
|
let transition = (constraints && constraints[axis]) || {};
|
|
@@ -11293,9 +11376,15 @@ class VisualElementDragControls {
|
|
|
11293
11376
|
const stopLayoutUpdateListener = projection.addEventListener("didUpdate", (({ delta, hasLayoutChanged }) => {
|
|
11294
11377
|
if (this.isDragging && hasLayoutChanged) {
|
|
11295
11378
|
eachAxis((axis) => {
|
|
11296
|
-
|
|
11297
|
-
|
|
11379
|
+
/**
|
|
11380
|
+
* Only compensate axes this gesture drags. A
|
|
11381
|
+
* non-drag axis follows its layout instead, as
|
|
11382
|
+
* nothing would ever move it back (e.g. snapping
|
|
11383
|
+
* to origin only animates drag axes).
|
|
11384
|
+
*/
|
|
11385
|
+
if (!shouldDrag(axis, this.getProps().drag, this.currentDirection))
|
|
11298
11386
|
return;
|
|
11387
|
+
const motionValue = this.getAxisMotionValue(axis);
|
|
11299
11388
|
this.originPoint[axis] += delta[axis].translate;
|
|
11300
11389
|
motionValue.set(motionValue.get() + delta[axis].translate);
|
|
11301
11390
|
});
|
|
@@ -13770,8 +13859,7 @@ function createAnimationState(visualElement) {
|
|
|
13770
13859
|
const valueHasChanged = Array.isArray(next) && Array.isArray(prev)
|
|
13771
13860
|
? !shallowCompare(next, prev) || variantDidChange
|
|
13772
13861
|
: next !== prev;
|
|
13773
|
-
if (valueHasChanged &&
|
|
13774
|
-
(next === undefined || next === null)) {
|
|
13862
|
+
if (valueHasChanged && (next === undefined || next === null)) {
|
|
13775
13863
|
removedKeys.add(key);
|
|
13776
13864
|
}
|
|
13777
13865
|
else if (valueHasChanged ||
|
|
@@ -14238,6 +14326,7 @@ exports.pixelsToPercent = pixelsToPercent;
|
|
|
14238
14326
|
exports.positionalKeys = positionalKeys;
|
|
14239
14327
|
exports.prefersReducedMotion = prefersReducedMotion;
|
|
14240
14328
|
exports.press = press;
|
|
14329
|
+
exports.processFrame = processFrame;
|
|
14241
14330
|
exports.progressPercentage = progressPercentage;
|
|
14242
14331
|
exports.propEffect = propEffect;
|
|
14243
14332
|
exports.propagateDirtyNodes = propagateDirtyNodes;
|