motion-dom 14.4.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 +413 -79
- 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/animate/element.mjs +10 -1
- package/dist/es/animation/animate/element.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/gestures/drag/index.mjs +16 -1
- package/dist/es/gestures/drag/index.mjs.map +1 -1
- package/dist/es/gestures/hover.mjs +2 -0
- package/dist/es/gestures/hover.mjs.map +1 -1
- package/dist/es/gestures/pan/PanSession.mjs +6 -0
- package/dist/es/gestures/pan/PanSession.mjs.map +1 -1
- package/dist/es/gestures/press/index.mjs +3 -1
- package/dist/es/gestures/press/index.mjs.map +1 -1
- package/dist/es/gestures/press/utils/keyboard.mjs +22 -12
- package/dist/es/gestures/press/utils/keyboard.mjs.map +1 -1
- package/dist/es/gestures/utils/setup.mjs +2 -1
- package/dist/es/gestures/utils/setup.mjs.map +1 -1
- package/dist/es/index.mjs +7 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/layout/LayoutAnimationBuilder.mjs +2 -1
- package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
- package/dist/es/layout/animate-layout.mjs +7 -1
- package/dist/es/layout/animate-layout.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/es/resize/index.mjs +2 -1
- package/dist/es/resize/index.mjs.map +1 -1
- package/dist/es/scope/active.mjs +39 -0
- package/dist/es/scope/active.mjs.map +1 -0
- package/dist/es/scope/index.mjs +122 -0
- package/dist/es/scope/index.mjs.map +1 -0
- package/dist/es/scope/media.mjs +42 -0
- package/dist/es/scope/media.mjs.map +1 -0
- package/dist/es/utils/delay.mjs +3 -1
- package/dist/es/utils/delay.mjs.map +1 -1
- package/dist/es/utils/resolve-elements.mjs +5 -4
- package/dist/es/utils/resolve-elements.mjs.map +1 -1
- package/dist/es/view/index.mjs +4 -1
- package/dist/es/view/index.mjs.map +1 -1
- package/dist/index.d.ts +178 -15
- package/dist/motion-dom.dev.js +413 -79
- 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 +4 -4
package/dist/motion-dom.dev.js
CHANGED
|
@@ -621,6 +621,11 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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];
|
|
@@ -2302,7 +2318,7 @@
|
|
|
2302
2318
|
|
|
2303
2319
|
const isNumOrPxType = (v) => v === number || v === px;
|
|
2304
2320
|
const transformKeys = new Set(["x", "y", "z"]);
|
|
2305
|
-
const nonTranslationalTransformKeys = transformPropOrder.filter((key) => !transformKeys.has(key));
|
|
2321
|
+
const nonTranslationalTransformKeys = /* @__PURE__ */ transformPropOrder.filter((key) => !transformKeys.has(key));
|
|
2306
2322
|
/**
|
|
2307
2323
|
* Reset any bounding box-changing transforms so the element can be
|
|
2308
2324
|
* measured. Returns the values to restore. Values already at their
|
|
@@ -2344,6 +2360,8 @@
|
|
|
2344
2360
|
? size
|
|
2345
2361
|
: size - parseFloat(paddingStart) - parseFloat(paddingEnd);
|
|
2346
2362
|
}
|
|
2363
|
+
const transformX = ({ transform }) => parseValueFromTransform(transform, "x");
|
|
2364
|
+
const transformY = ({ transform }) => parseValueFromTransform(transform, "y");
|
|
2347
2365
|
const positionalValues = {
|
|
2348
2366
|
// Dimensions
|
|
2349
2367
|
width: ({ width, paddingLeft = "0", paddingRight = "0", boxSizing }, measureBox) => measureDimension(width, measureBox, "x", paddingLeft, paddingRight, boxSizing),
|
|
@@ -2358,13 +2376,12 @@
|
|
|
2358
2376
|
const { x } = measureBox();
|
|
2359
2377
|
return parseFloat(left) + (x.max - x.min);
|
|
2360
2378
|
},
|
|
2361
|
-
// Transform
|
|
2362
|
-
x:
|
|
2363
|
-
y:
|
|
2379
|
+
// Transform, including translate longform names
|
|
2380
|
+
x: transformX,
|
|
2381
|
+
y: transformY,
|
|
2382
|
+
translateX: transformX,
|
|
2383
|
+
translateY: transformY,
|
|
2364
2384
|
};
|
|
2365
|
-
// Alias translate longform names
|
|
2366
|
-
positionalValues.translateX = positionalValues.x;
|
|
2367
|
-
positionalValues.translateY = positionalValues.y;
|
|
2368
2385
|
|
|
2369
2386
|
const toResolve = new Set();
|
|
2370
2387
|
let isScheduled = false;
|
|
@@ -2718,18 +2735,24 @@
|
|
|
2718
2735
|
if (this.isStopped)
|
|
2719
2736
|
return;
|
|
2720
2737
|
this.isStopped = true;
|
|
2721
|
-
|
|
2722
|
-
|
|
2738
|
+
/**
|
|
2739
|
+
* Before its finish event, a finished animation (an instant one is
|
|
2740
|
+
* as soon as it starts) is still showing its end, so it's stopped
|
|
2741
|
+
* like a running one. Otherwise that event would apply its end
|
|
2742
|
+
* over whatever animates the value next.
|
|
2743
|
+
*/
|
|
2744
|
+
if (this.state === "idle" || this.finishedTime !== null)
|
|
2723
2745
|
return;
|
|
2724
|
-
}
|
|
2725
2746
|
if (this.updateMotionValue) {
|
|
2726
2747
|
this.updateMotionValue();
|
|
2727
2748
|
}
|
|
2728
2749
|
else {
|
|
2729
2750
|
this.commitStyles();
|
|
2730
2751
|
}
|
|
2731
|
-
if (!this.isPseudoElement)
|
|
2752
|
+
if (!this.isPseudoElement) {
|
|
2753
|
+
this.animation.onfinish = null;
|
|
2732
2754
|
this.cancel();
|
|
2755
|
+
}
|
|
2733
2756
|
}
|
|
2734
2757
|
/**
|
|
2735
2758
|
* WAAPI doesn't natively have any interruption capabilities.
|
|
@@ -3038,7 +3061,13 @@
|
|
|
3038
3061
|
"borderBottomColor",
|
|
3039
3062
|
"borderLeftColor",
|
|
3040
3063
|
]);
|
|
3041
|
-
|
|
3064
|
+
/**
|
|
3065
|
+
* WAAPI runs on the browser's clock, so on a manual clock every animation
|
|
3066
|
+
* runs in JS where processFrame can drive it. Set the flag before starting
|
|
3067
|
+
* animations: running WAAPI animations stay on the browser's clock.
|
|
3068
|
+
*/
|
|
3069
|
+
const supportsWaapi = () => !motionUtils.MotionGlobalConfig.useManualTiming &&
|
|
3070
|
+
Object.hasOwnProperty.call(Element.prototype, "animate");
|
|
3042
3071
|
function supportsBrowserAnimation(options) {
|
|
3043
3072
|
const { motionValue, name, repeatDelay, repeatType, damping, type, keyframes, } = options;
|
|
3044
3073
|
/**
|
|
@@ -5229,12 +5258,8 @@
|
|
|
5229
5258
|
}
|
|
5230
5259
|
}
|
|
5231
5260
|
|
|
5232
|
-
function camelToDash(str) {
|
|
5233
|
-
return str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
|
|
5234
|
-
}
|
|
5235
|
-
|
|
5236
5261
|
const optimizedAppearDataId = "framerAppearId";
|
|
5237
|
-
const optimizedAppearDataAttribute = "data-"
|
|
5262
|
+
const optimizedAppearDataAttribute = "data-framer-appear-id";
|
|
5238
5263
|
|
|
5239
5264
|
function getOptimisedAppearId(visualElement) {
|
|
5240
5265
|
return visualElement.props[optimizedAppearDataAttribute];
|
|
@@ -5829,6 +5854,43 @@
|
|
|
5829
5854
|
return motionUtils.isObject(element) && "ownerSVGElement" in element;
|
|
5830
5855
|
}
|
|
5831
5856
|
|
|
5857
|
+
const activeScope = {};
|
|
5858
|
+
/**
|
|
5859
|
+
* Register `cleanup` with the active scope, if there is one, so stopping
|
|
5860
|
+
* the scope also runs it.
|
|
5861
|
+
*/
|
|
5862
|
+
function addToScope(cleanup) {
|
|
5863
|
+
activeScope.current?.add(cleanup);
|
|
5864
|
+
return cleanup;
|
|
5865
|
+
}
|
|
5866
|
+
/**
|
|
5867
|
+
* Collect the animation a builder like `animateLayout()` or
|
|
5868
|
+
* `animateView()` resolves with. If the scope stops first, the animation
|
|
5869
|
+
* is stopped as soon as it starts.
|
|
5870
|
+
*/
|
|
5871
|
+
function addBuilderToScope(builder) {
|
|
5872
|
+
const scope = activeScope.current;
|
|
5873
|
+
if (!scope)
|
|
5874
|
+
return;
|
|
5875
|
+
let isStopped = false;
|
|
5876
|
+
let stop;
|
|
5877
|
+
const remove = scope.add(() => {
|
|
5878
|
+
isStopped = true;
|
|
5879
|
+
stop?.();
|
|
5880
|
+
});
|
|
5881
|
+
builder.then((animation) => {
|
|
5882
|
+
if (!animation)
|
|
5883
|
+
return;
|
|
5884
|
+
stop = () => animation.stop();
|
|
5885
|
+
isStopped ? stop() : animation.finished.then(remove);
|
|
5886
|
+
}, remove);
|
|
5887
|
+
}
|
|
5888
|
+
/**
|
|
5889
|
+
* Bind `callback` to the active scope, so anything it starts later (for
|
|
5890
|
+
* instance an animation in an `inView()` callback) is collected too.
|
|
5891
|
+
*/
|
|
5892
|
+
const bindToScope = (callback) => activeScope.current ? activeScope.current.bind(callback) : callback;
|
|
5893
|
+
|
|
5832
5894
|
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
5833
5895
|
if (elementOrSelector == null) {
|
|
5834
5896
|
return [];
|
|
@@ -5837,10 +5899,9 @@
|
|
|
5837
5899
|
return [elementOrSelector];
|
|
5838
5900
|
}
|
|
5839
5901
|
else if (typeof elementOrSelector === "string") {
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
root
|
|
5843
|
-
}
|
|
5902
|
+
const root = scope
|
|
5903
|
+
? scope.current
|
|
5904
|
+
: activeScope.current?.root || document;
|
|
5844
5905
|
const elements = selectorCache?.[elementOrSelector] ??
|
|
5845
5906
|
root.querySelectorAll(elementOrSelector);
|
|
5846
5907
|
return elements ? Array.from(elements) : [];
|
|
@@ -6126,6 +6187,10 @@
|
|
|
6126
6187
|
const styleEffect =
|
|
6127
6188
|
/*@__PURE__*/ createSelectorEffect(styleSubjectEffect);
|
|
6128
6189
|
|
|
6190
|
+
function camelToDash(str) {
|
|
6191
|
+
return str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
|
|
6192
|
+
}
|
|
6193
|
+
|
|
6129
6194
|
function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
6130
6195
|
const { style, vars, transformOrigin } = state;
|
|
6131
6196
|
// Track whether we encounter any transform or transformOrigin values.
|
|
@@ -6630,12 +6695,20 @@
|
|
|
6630
6695
|
* sharing values and a renderer.
|
|
6631
6696
|
*/
|
|
6632
6697
|
function animateElement(element, keyframes, transition, visualElement) {
|
|
6698
|
+
activeScope.current?.track(element);
|
|
6633
6699
|
if (visualElement) {
|
|
6634
6700
|
return animateValues((key) => visualElement.getValue(key, null), keyframes, transition, visualElement);
|
|
6635
6701
|
}
|
|
6636
6702
|
const effect = getElementEffect(element);
|
|
6637
6703
|
return animateEffectSubject(effect, element, keyframes, transition, new EffectSubject(effect, element));
|
|
6638
6704
|
}
|
|
6705
|
+
/**
|
|
6706
|
+
* Detach the values styleEffect/svgEffect bound to `element`, so the
|
|
6707
|
+
* next animation reads its starting values from the DOM again.
|
|
6708
|
+
*/
|
|
6709
|
+
const releaseElement = (element) => getElementEffect(element)
|
|
6710
|
+
.state(element)
|
|
6711
|
+
?.release();
|
|
6639
6712
|
/**
|
|
6640
6713
|
* Hand the values styleEffect/svgEffect are rendering on `element`,
|
|
6641
6714
|
* whether bound by animate() or directly, to a VisualElement that now
|
|
@@ -6693,6 +6766,41 @@
|
|
|
6693
6766
|
const { schedule: microtask, cancel: cancelMicrotask } =
|
|
6694
6767
|
/* @__PURE__ */ createRenderBatcher(queueMicrotask, false);
|
|
6695
6768
|
|
|
6769
|
+
/**
|
|
6770
|
+
* Process a frame now, for driving Motion from a loop other than
|
|
6771
|
+
* window.requestAnimationFrame, like an XRSession's during an immersive
|
|
6772
|
+
* WebXR session. Wherever window.requestAnimationFrame does fire, Motion
|
|
6773
|
+
* keeps processing frames from it too.
|
|
6774
|
+
*
|
|
6775
|
+
* `timestamp` defaults to now. For a timeline you control, set
|
|
6776
|
+
* `MotionGlobalConfig.useManualTiming = true` and pass each frame's time in
|
|
6777
|
+
* milliseconds.
|
|
6778
|
+
*
|
|
6779
|
+
* Animations Motion hands to the browser (WAAPI), like `opacity` or
|
|
6780
|
+
* `transform` on an HTML or SVG element, follow the browser's clock. With
|
|
6781
|
+
* `useManualTiming` on, Motion runs those in JS instead, except for
|
|
6782
|
+
* `motion/mini`, view transitions and optimized appear animations, and
|
|
6783
|
+
* colours only the browser can mix, like `oklch()`, which jump to their end.
|
|
6784
|
+
*
|
|
6785
|
+
* Ignored when called inside a frame.
|
|
6786
|
+
*/
|
|
6787
|
+
const processFrame = (timestamp = time.now()) => {
|
|
6788
|
+
if (frameData.isProcessing)
|
|
6789
|
+
return;
|
|
6790
|
+
const delta = timestamp - frameData.timestamp;
|
|
6791
|
+
// Clamp like the requestAnimationFrame loop, unless the timeline is ours
|
|
6792
|
+
frameData.delta = motionUtils.MotionGlobalConfig.useManualTiming
|
|
6793
|
+
? delta
|
|
6794
|
+
: Math.max(Math.min(delta, 40), 1);
|
|
6795
|
+
time.set((frameData.timestamp = timestamp));
|
|
6796
|
+
frameData.isProcessing = true;
|
|
6797
|
+
// frameSteps' keys are in stepsOrder
|
|
6798
|
+
for (const step in frameSteps) {
|
|
6799
|
+
frameSteps[step].process(frameData);
|
|
6800
|
+
}
|
|
6801
|
+
frameData.isProcessing = false;
|
|
6802
|
+
};
|
|
6803
|
+
|
|
6696
6804
|
function animateSingleValue(value, keyframes, options) {
|
|
6697
6805
|
const motionValue$1 = isMotionValue(value) ? value : motionValue(value);
|
|
6698
6806
|
motionValue$1.start(animateMotionValue("", motionValue$1, keyframes, options));
|
|
@@ -6726,6 +6834,7 @@
|
|
|
6726
6834
|
*/
|
|
6727
6835
|
function delay(callback, timeout) {
|
|
6728
6836
|
const start = time.now();
|
|
6837
|
+
callback = bindToScope(callback);
|
|
6729
6838
|
const checkElapsed = ({ timestamp }) => {
|
|
6730
6839
|
const elapsed = timestamp - start;
|
|
6731
6840
|
if (elapsed >= timeout) {
|
|
@@ -6734,7 +6843,7 @@
|
|
|
6734
6843
|
}
|
|
6735
6844
|
};
|
|
6736
6845
|
frame.setup(checkElapsed, true);
|
|
6737
|
-
return () => cancelFrame(checkElapsed);
|
|
6846
|
+
return addToScope(() => cancelFrame(checkElapsed));
|
|
6738
6847
|
}
|
|
6739
6848
|
function delayInSeconds(callback, timeout) {
|
|
6740
6849
|
return delay(callback, motionUtils.secondsToMilliseconds(timeout));
|
|
@@ -7158,10 +7267,9 @@
|
|
|
7158
7267
|
};
|
|
7159
7268
|
|
|
7160
7269
|
const defaultScaleCorrectors = {
|
|
7161
|
-
borderRadius: {
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
},
|
|
7270
|
+
borderRadius: /* @__PURE__ */ Object.assign({}, correctBorderRadius, {
|
|
7271
|
+
applyTo: /* @__PURE__ */ cornerRadiusProps.slice(),
|
|
7272
|
+
}),
|
|
7165
7273
|
borderTopLeftRadius: correctBorderRadius,
|
|
7166
7274
|
borderTopRightRadius: correctBorderRadius,
|
|
7167
7275
|
borderBottomLeftRadius: correctBorderRadius,
|
|
@@ -7266,14 +7374,6 @@
|
|
|
7266
7374
|
hasEverUpdated: false,
|
|
7267
7375
|
};
|
|
7268
7376
|
|
|
7269
|
-
/**
|
|
7270
|
-
* Correctors registered via addScaleCorrector before projection loaded
|
|
7271
|
-
* (e.g. with an async LazyMotion bundle) take precedence over the defaults.
|
|
7272
|
-
*/
|
|
7273
|
-
Object.assign(scaleCorrectors, {
|
|
7274
|
-
...defaultScaleCorrectors,
|
|
7275
|
-
...scaleCorrectors,
|
|
7276
|
-
});
|
|
7277
7377
|
const metrics = {
|
|
7278
7378
|
nodes: 0,
|
|
7279
7379
|
calculatedTargetDeltas: 0,
|
|
@@ -7316,6 +7416,16 @@
|
|
|
7316
7416
|
}
|
|
7317
7417
|
}
|
|
7318
7418
|
function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
|
|
7419
|
+
/**
|
|
7420
|
+
* Correctors registered via addScaleCorrector before projection loaded
|
|
7421
|
+
* (e.g. with an async LazyMotion bundle) take precedence over the defaults.
|
|
7422
|
+
* Applied here rather than at module scope so bundlers can drop projection
|
|
7423
|
+
* when it's unused.
|
|
7424
|
+
*/
|
|
7425
|
+
Object.assign(scaleCorrectors, {
|
|
7426
|
+
...defaultScaleCorrectors,
|
|
7427
|
+
...scaleCorrectors,
|
|
7428
|
+
});
|
|
7319
7429
|
return class ProjectionNode {
|
|
7320
7430
|
constructor(latestValues = {}, parent = defaultParent?.()) {
|
|
7321
7431
|
/**
|
|
@@ -7972,7 +8082,7 @@
|
|
|
7972
8082
|
}
|
|
7973
8083
|
return boxWithoutScroll;
|
|
7974
8084
|
}
|
|
7975
|
-
applyTransform(box, transformOnly = false, output) {
|
|
8085
|
+
applyTransform(box, transformOnly = false, output, skipOwnTransform) {
|
|
7976
8086
|
const withTransforms = output || createBox();
|
|
7977
8087
|
copyBoxInto(withTransforms, box);
|
|
7978
8088
|
for (let i = 0; i < this.path.length; i++) {
|
|
@@ -7988,7 +8098,7 @@
|
|
|
7988
8098
|
continue;
|
|
7989
8099
|
transformBox(withTransforms, node.latestValues, node.layout?.layoutBox);
|
|
7990
8100
|
}
|
|
7991
|
-
if (hasTransform(this.latestValues)) {
|
|
8101
|
+
if (!skipOwnTransform && hasTransform(this.latestValues)) {
|
|
7992
8102
|
transformBox(withTransforms, this.latestValues, this.layout?.layoutBox);
|
|
7993
8103
|
}
|
|
7994
8104
|
return withTransforms;
|
|
@@ -8123,7 +8233,11 @@
|
|
|
8123
8233
|
}
|
|
8124
8234
|
else if (this.targetDelta) {
|
|
8125
8235
|
if (Boolean(this.resumingFrom)) {
|
|
8126
|
-
|
|
8236
|
+
/**
|
|
8237
|
+
* Own transforms are applied later, in applyTransformsToTarget,
|
|
8238
|
+
* so only apply ancestor transforms here or they'd be doubled.
|
|
8239
|
+
*/
|
|
8240
|
+
this.applyTransform(this.layout.layoutBox, false, this.target, true);
|
|
8127
8241
|
}
|
|
8128
8242
|
else {
|
|
8129
8243
|
copyBoxInto(this.target, this.layout.layoutBox);
|
|
@@ -8892,10 +9006,13 @@
|
|
|
8892
9006
|
* A dragged node doesn't layout animate, so it jumps to its new layout. Shift
|
|
8893
9007
|
* its descendants' snapshots by the same amount, so they only animate layout
|
|
8894
9008
|
* changes relative to it, rather than lagging behind.
|
|
9009
|
+
*
|
|
9010
|
+
* If its drag ended since the snapshot (e.g. drag disabled from onDrag), it
|
|
9011
|
+
* layout animates again, so its descendants mustn't follow its jump.
|
|
8895
9012
|
*/
|
|
8896
9013
|
function followDraggedAncestor(node) {
|
|
8897
9014
|
const { snapshot, dragAncestor } = node;
|
|
8898
|
-
const to = dragAncestor?.layout;
|
|
9015
|
+
const to = dragAncestor?.isAnimationBlocked && dragAncestor.layout;
|
|
8899
9016
|
if (!snapshot || !to || node.resumeFrom || node.isAnimationBlocked)
|
|
8900
9017
|
return;
|
|
8901
9018
|
const from = dragAncestor.dragSnapshot;
|
|
@@ -9009,11 +9126,16 @@
|
|
|
9009
9126
|
return () => target.removeEventListener(eventName, handler, options);
|
|
9010
9127
|
}
|
|
9011
9128
|
|
|
9012
|
-
const DocumentProjectionNode =
|
|
9129
|
+
const DocumentProjectionNode =
|
|
9130
|
+
/* @__PURE__ */ createProjectionNode({
|
|
9013
9131
|
attachResizeListener: (ref, notify) => addDomEvent(ref, "resize", notify),
|
|
9014
9132
|
measureScroll: () => ({
|
|
9015
|
-
x: document.documentElement.scrollLeft ||
|
|
9016
|
-
|
|
9133
|
+
x: document.documentElement.scrollLeft ||
|
|
9134
|
+
document.body?.scrollLeft ||
|
|
9135
|
+
0,
|
|
9136
|
+
y: document.documentElement.scrollTop ||
|
|
9137
|
+
document.body?.scrollTop ||
|
|
9138
|
+
0,
|
|
9017
9139
|
}),
|
|
9018
9140
|
checkIsScrollRoot: () => true,
|
|
9019
9141
|
});
|
|
@@ -9021,7 +9143,9 @@
|
|
|
9021
9143
|
const rootProjectionNode = {
|
|
9022
9144
|
current: undefined,
|
|
9023
9145
|
};
|
|
9024
|
-
|
|
9146
|
+
|
|
9147
|
+
const HTMLProjectionNode =
|
|
9148
|
+
/* @__PURE__ */ createProjectionNode({
|
|
9025
9149
|
measureScroll: (instance) => ({
|
|
9026
9150
|
x: instance.scrollLeft,
|
|
9027
9151
|
y: instance.scrollTop,
|
|
@@ -9065,7 +9189,7 @@
|
|
|
9065
9189
|
"whileDrag",
|
|
9066
9190
|
"exit",
|
|
9067
9191
|
];
|
|
9068
|
-
const variantProps = ["initial"
|
|
9192
|
+
const variantProps = /* @__PURE__ */ ["initial"].concat(variantPriorityOrder);
|
|
9069
9193
|
|
|
9070
9194
|
function isControllingVariants(props) {
|
|
9071
9195
|
if (isAnimationControls(props.animate))
|
|
@@ -10148,7 +10272,7 @@
|
|
|
10148
10272
|
function parseAnimateLayoutArgs(scopeOrUpdateDom, updateDomOrOptions, options) {
|
|
10149
10273
|
if (typeof scopeOrUpdateDom === "function") {
|
|
10150
10274
|
return {
|
|
10151
|
-
scope: document,
|
|
10275
|
+
scope: activeScope.current?.root || document,
|
|
10152
10276
|
updateDom: scopeOrUpdateDom,
|
|
10153
10277
|
defaultOptions: updateDomOrOptions,
|
|
10154
10278
|
};
|
|
@@ -10284,7 +10408,7 @@
|
|
|
10284
10408
|
}
|
|
10285
10409
|
|
|
10286
10410
|
function resize(a, b) {
|
|
10287
|
-
return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
|
|
10411
|
+
return addToScope(typeof a === "function" ? resizeWindow(a) : resizeElement(a, b));
|
|
10288
10412
|
}
|
|
10289
10413
|
|
|
10290
10414
|
const distance = (a, b) => Math.abs(a - b);
|
|
@@ -10349,6 +10473,12 @@
|
|
|
10349
10473
|
onMove && onMove(this.lastMoveEvent, info);
|
|
10350
10474
|
};
|
|
10351
10475
|
this.handlePointerMove = (event, info) => {
|
|
10476
|
+
/**
|
|
10477
|
+
* This event's pageX/pageY already include any window scroll that
|
|
10478
|
+
* hasn't fired its scroll event yet. Settle it now, so that scroll
|
|
10479
|
+
* event doesn't add it to the new point a second time.
|
|
10480
|
+
*/
|
|
10481
|
+
this.handleScroll(window);
|
|
10352
10482
|
this.lastMoveEvent = event;
|
|
10353
10483
|
this.lastRawMoveEventInfo = info;
|
|
10354
10484
|
this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint);
|
|
@@ -10905,7 +11035,11 @@
|
|
|
10905
11035
|
element: this.visualElement.current,
|
|
10906
11036
|
});
|
|
10907
11037
|
}
|
|
10908
|
-
|
|
11038
|
+
/**
|
|
11039
|
+
* @param dragAxes - The axes to animate on release, if not the `drag`
|
|
11040
|
+
* prop's, e.g. when drag was disabled mid-gesture.
|
|
11041
|
+
*/
|
|
11042
|
+
stop(event, panInfo, dragAxes) {
|
|
10909
11043
|
const finalEvent = event || this.latestPointerEvent;
|
|
10910
11044
|
const finalPanInfo = panInfo || this.latestPanInfo;
|
|
10911
11045
|
const isDragging = this.isDragging;
|
|
@@ -10913,7 +11047,7 @@
|
|
|
10913
11047
|
if (!isDragging || !finalPanInfo || !finalEvent)
|
|
10914
11048
|
return;
|
|
10915
11049
|
const { velocity } = finalPanInfo;
|
|
10916
|
-
this.startAnimation(velocity);
|
|
11050
|
+
this.startAnimation(velocity, dragAxes);
|
|
10917
11051
|
const { onDragEnd } = this.getProps();
|
|
10918
11052
|
if (onDragEnd) {
|
|
10919
11053
|
frame.postRender(() => onDragEnd(finalEvent, finalPanInfo));
|
|
@@ -11034,11 +11168,11 @@
|
|
|
11034
11168
|
}
|
|
11035
11169
|
return measuredConstraints;
|
|
11036
11170
|
}
|
|
11037
|
-
startAnimation(velocity) {
|
|
11171
|
+
startAnimation(velocity, dragAxes) {
|
|
11038
11172
|
const { drag, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd, } = this.getProps();
|
|
11039
11173
|
const constraints = this.constraints || {};
|
|
11040
11174
|
const momentumAnimations = eachAxis((axis) => {
|
|
11041
|
-
if (!shouldDrag(axis, drag, this.currentDirection)) {
|
|
11175
|
+
if (!shouldDrag(axis, dragAxes || drag, this.currentDirection)) {
|
|
11042
11176
|
return;
|
|
11043
11177
|
}
|
|
11044
11178
|
let transition = (constraints && constraints[axis]) || {};
|
|
@@ -11241,9 +11375,15 @@
|
|
|
11241
11375
|
const stopLayoutUpdateListener = projection.addEventListener("didUpdate", (({ delta, hasLayoutChanged }) => {
|
|
11242
11376
|
if (this.isDragging && hasLayoutChanged) {
|
|
11243
11377
|
eachAxis((axis) => {
|
|
11244
|
-
|
|
11245
|
-
|
|
11378
|
+
/**
|
|
11379
|
+
* Only compensate axes this gesture drags. A
|
|
11380
|
+
* non-drag axis follows its layout instead, as
|
|
11381
|
+
* nothing would ever move it back (e.g. snapping
|
|
11382
|
+
* to origin only animates drag axes).
|
|
11383
|
+
*/
|
|
11384
|
+
if (!shouldDrag(axis, this.getProps().drag, this.currentDirection))
|
|
11246
11385
|
return;
|
|
11386
|
+
const motionValue = this.getAxisMotionValue(axis);
|
|
11247
11387
|
this.originPoint[axis] += delta[axis].translate;
|
|
11248
11388
|
motionValue.set(motionValue.get() + delta[axis].translate);
|
|
11249
11389
|
});
|
|
@@ -11380,7 +11520,20 @@
|
|
|
11380
11520
|
*/
|
|
11381
11521
|
function drag(elementOrSelector, options = {}) {
|
|
11382
11522
|
const props = toProps(options);
|
|
11523
|
+
const scope = activeScope.current;
|
|
11524
|
+
/**
|
|
11525
|
+
* Run callbacks in the active scope, so work they start is collected.
|
|
11526
|
+
*/
|
|
11527
|
+
if (scope) {
|
|
11528
|
+
for (const key in props) {
|
|
11529
|
+
const value = props[key];
|
|
11530
|
+
if (typeof value === "function") {
|
|
11531
|
+
props[key] = scope.bind(value);
|
|
11532
|
+
}
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11383
11535
|
const cleanups = resolveElements(elementOrSelector).map((element) => {
|
|
11536
|
+
scope?.track(element);
|
|
11384
11537
|
const [node, release] = acquireProjectionNode(element);
|
|
11385
11538
|
/**
|
|
11386
11539
|
* Measure layout even when not animating it, as constraints and
|
|
@@ -11394,10 +11547,11 @@
|
|
|
11394
11547
|
removeStyles();
|
|
11395
11548
|
removeListeners?.();
|
|
11396
11549
|
controls.cancel();
|
|
11550
|
+
controls.stopAnimation();
|
|
11397
11551
|
release();
|
|
11398
11552
|
};
|
|
11399
11553
|
});
|
|
11400
|
-
return () => cleanups.forEach((cleanup) => cleanup());
|
|
11554
|
+
return addToScope(() => cleanups.forEach((cleanup) => cleanup()));
|
|
11401
11555
|
}
|
|
11402
11556
|
|
|
11403
11557
|
function setupGesture(elementOrSelector, options) {
|
|
@@ -11408,7 +11562,7 @@
|
|
|
11408
11562
|
...options,
|
|
11409
11563
|
signal: gestureAbortController.signal,
|
|
11410
11564
|
};
|
|
11411
|
-
const cancel = () => gestureAbortController.abort();
|
|
11565
|
+
const cancel = addToScope(() => gestureAbortController.abort());
|
|
11412
11566
|
return [elements, eventOptions, cancel];
|
|
11413
11567
|
}
|
|
11414
11568
|
|
|
@@ -11423,6 +11577,7 @@
|
|
|
11423
11577
|
* @public
|
|
11424
11578
|
*/
|
|
11425
11579
|
function hover(elementOrSelector, onHoverStart, options = {}) {
|
|
11580
|
+
onHoverStart = bindToScope(onHoverStart);
|
|
11426
11581
|
const [elements, eventOptions, cancel] = setupGesture(elementOrSelector, options);
|
|
11427
11582
|
elements.forEach((element) => {
|
|
11428
11583
|
let isPressed = false;
|
|
@@ -11511,26 +11666,36 @@
|
|
|
11511
11666
|
function firePointerEvent(target, type) {
|
|
11512
11667
|
target.dispatchEvent(new PointerEvent("pointer" + type, { isPrimary: true, bubbles: true }));
|
|
11513
11668
|
}
|
|
11514
|
-
const enableKeyboardPress = (
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11669
|
+
const enableKeyboardPress = (element, eventOptions) => {
|
|
11670
|
+
/**
|
|
11671
|
+
* Listeners are scoped to this focus and all released on blur, rather
|
|
11672
|
+
* than added per Enter press, so they can't accumulate and fire
|
|
11673
|
+
* duplicate pointerup/pointercancel events. See #3935.
|
|
11674
|
+
*/
|
|
11675
|
+
let isKeyPressing = false;
|
|
11518
11676
|
const handleKeydown = filterEvents(() => {
|
|
11519
11677
|
if (isPressing.has(element))
|
|
11520
11678
|
return;
|
|
11679
|
+
isKeyPressing = true;
|
|
11521
11680
|
firePointerEvent(element, "down");
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
element
|
|
11681
|
+
});
|
|
11682
|
+
const handleKeyup = filterEvents(() => {
|
|
11683
|
+
if (!isKeyPressing)
|
|
11684
|
+
return;
|
|
11685
|
+
isKeyPressing = false;
|
|
11686
|
+
firePointerEvent(element, "up");
|
|
11528
11687
|
});
|
|
11529
11688
|
element.addEventListener("keydown", handleKeydown, eventOptions);
|
|
11689
|
+
element.addEventListener("keyup", handleKeyup, eventOptions);
|
|
11530
11690
|
/**
|
|
11531
|
-
*
|
|
11691
|
+
* On blur, remove the key listeners and cancel any keyboard press.
|
|
11532
11692
|
*/
|
|
11533
|
-
element.addEventListener("blur", () =>
|
|
11693
|
+
element.addEventListener("blur", () => {
|
|
11694
|
+
element.removeEventListener("keydown", handleKeydown);
|
|
11695
|
+
element.removeEventListener("keyup", handleKeyup);
|
|
11696
|
+
if (isKeyPressing)
|
|
11697
|
+
firePointerEvent(element, "cancel");
|
|
11698
|
+
}, { ...eventOptions, once: true });
|
|
11534
11699
|
};
|
|
11535
11700
|
|
|
11536
11701
|
/**
|
|
@@ -11561,6 +11726,7 @@
|
|
|
11561
11726
|
* @public
|
|
11562
11727
|
*/
|
|
11563
11728
|
function press(targetOrSelector, onPressStart, options = {}) {
|
|
11729
|
+
onPressStart = bindToScope(onPressStart);
|
|
11564
11730
|
const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
|
|
11565
11731
|
const startPress = (startEvent) => {
|
|
11566
11732
|
const target = startEvent.currentTarget;
|
|
@@ -11609,7 +11775,7 @@
|
|
|
11609
11775
|
const pointerDownTarget = options.useGlobalTarget ? window : target;
|
|
11610
11776
|
pointerDownTarget.addEventListener("pointerdown", startPress, eventOptions);
|
|
11611
11777
|
if (isHTMLElement(target)) {
|
|
11612
|
-
target.addEventListener("focus", (
|
|
11778
|
+
target.addEventListener("focus", () => enableKeyboardPress(target, eventOptions), eventOptions);
|
|
11613
11779
|
if (!isElementKeyboardAccessible(target) &&
|
|
11614
11780
|
!target.hasAttribute("tabindex")) {
|
|
11615
11781
|
target.tabIndex = 0;
|
|
@@ -11626,6 +11792,160 @@
|
|
|
11626
11792
|
: computedStyle[name];
|
|
11627
11793
|
}
|
|
11628
11794
|
|
|
11795
|
+
const keywords = {
|
|
11796
|
+
reducedMotion: "(prefers-reduced-motion: reduce)",
|
|
11797
|
+
motion: "(prefers-reduced-motion: no-preference)",
|
|
11798
|
+
dark: "(prefers-color-scheme: dark)",
|
|
11799
|
+
light: "(prefers-color-scheme: light)",
|
|
11800
|
+
hover: "(hover: hover) and (pointer: fine)",
|
|
11801
|
+
touch: "(pointer: coarse)",
|
|
11802
|
+
portrait: "(orientation: portrait)",
|
|
11803
|
+
landscape: "(orientation: landscape)",
|
|
11804
|
+
};
|
|
11805
|
+
/**
|
|
11806
|
+
* Turn a condition into a media query. Full media queries pass through
|
|
11807
|
+
* unchanged. Otherwise each space-separated token must match:
|
|
11808
|
+
*
|
|
11809
|
+
* - A width comparison: `">=800"`, `"<1200px"`, `"> 40em"`
|
|
11810
|
+
* - A keyword: `reducedMotion`, `motion`, `dark`, `light`, `hover`,
|
|
11811
|
+
* `touch`, `portrait`, `landscape`
|
|
11812
|
+
*
|
|
11813
|
+
* Prefix a token with `!` to negate it, for instance `">=800 !touch"`.
|
|
11814
|
+
*/
|
|
11815
|
+
function toMediaQuery(condition) {
|
|
11816
|
+
if (condition.includes("("))
|
|
11817
|
+
return condition;
|
|
11818
|
+
return condition
|
|
11819
|
+
.replace(/([<>!]=?)\s+/g, "$1")
|
|
11820
|
+
.trim()
|
|
11821
|
+
.split(/\s+/)
|
|
11822
|
+
.map((token) => {
|
|
11823
|
+
const isNot = token[0] === "!";
|
|
11824
|
+
if (isNot)
|
|
11825
|
+
token = token.slice(1);
|
|
11826
|
+
const width = /^([<>]=?)([\d.]+)([a-z]*)$/.exec(token);
|
|
11827
|
+
const query = width
|
|
11828
|
+
? `(width ${width[1]} ${width[2]}${width[3] || "px"})`
|
|
11829
|
+
: keywords[token] || token;
|
|
11830
|
+
return isNot ? `(not (${query}))` : query;
|
|
11831
|
+
})
|
|
11832
|
+
.join(" and ");
|
|
11833
|
+
}
|
|
11834
|
+
|
|
11835
|
+
function scopeMotion(...args) {
|
|
11836
|
+
const root = typeof args[0] === "function" ? undefined : args.shift();
|
|
11837
|
+
const [setup, options = {}] = args;
|
|
11838
|
+
const { transition, matchMedia } = options;
|
|
11839
|
+
const queries = [];
|
|
11840
|
+
const styles = new Map();
|
|
11841
|
+
let cleanups = [];
|
|
11842
|
+
let isPending = false;
|
|
11843
|
+
const active = {
|
|
11844
|
+
root: resolveElements(root)[0],
|
|
11845
|
+
transition,
|
|
11846
|
+
add(cleanup) {
|
|
11847
|
+
cleanups.push(cleanup);
|
|
11848
|
+
return () => motionUtils.removeItem(cleanups, cleanup);
|
|
11849
|
+
},
|
|
11850
|
+
bind: (callback) => ((...args) => {
|
|
11851
|
+
const result = scope.run(() => callback(...args));
|
|
11852
|
+
return typeof result === "function"
|
|
11853
|
+
? active.bind(result)
|
|
11854
|
+
: result;
|
|
11855
|
+
}),
|
|
11856
|
+
track(element) {
|
|
11857
|
+
styles.has(element) ||
|
|
11858
|
+
styles.set(element, element.getAttribute("style"));
|
|
11859
|
+
},
|
|
11860
|
+
};
|
|
11861
|
+
const clear = (restore) => {
|
|
11862
|
+
const current = cleanups;
|
|
11863
|
+
cleanups = [];
|
|
11864
|
+
for (let i = current.length - 1; i >= 0; i--)
|
|
11865
|
+
current[i]();
|
|
11866
|
+
restore &&
|
|
11867
|
+
styles.forEach((style, element) => {
|
|
11868
|
+
releaseElement(element);
|
|
11869
|
+
style === null
|
|
11870
|
+
? element.removeAttribute("style")
|
|
11871
|
+
: element.setAttribute("style", style);
|
|
11872
|
+
});
|
|
11873
|
+
styles.clear();
|
|
11874
|
+
};
|
|
11875
|
+
const start = () => {
|
|
11876
|
+
scope.state = "active";
|
|
11877
|
+
let matches = !queries.length;
|
|
11878
|
+
scope.media = {};
|
|
11879
|
+
for (const [name, query] of queries) {
|
|
11880
|
+
matches = (scope.media[name] = query.matches) || matches;
|
|
11881
|
+
}
|
|
11882
|
+
if (matches && setup) {
|
|
11883
|
+
const cleanup = scope.run(() => setup(scope));
|
|
11884
|
+
typeof cleanup === "function" && active.add(cleanup);
|
|
11885
|
+
}
|
|
11886
|
+
};
|
|
11887
|
+
const onChange = () => {
|
|
11888
|
+
if (isPending)
|
|
11889
|
+
return;
|
|
11890
|
+
isPending = true;
|
|
11891
|
+
/**
|
|
11892
|
+
* Several conditions can change together, for instance two
|
|
11893
|
+
* breakpoints crossed by one resize. Refresh once.
|
|
11894
|
+
*/
|
|
11895
|
+
queueMicrotask(() => {
|
|
11896
|
+
isPending = false;
|
|
11897
|
+
queries.length && scope.refresh();
|
|
11898
|
+
});
|
|
11899
|
+
};
|
|
11900
|
+
const kill = (restore) => {
|
|
11901
|
+
scope.state = restore ? "cancelled" : "stopped";
|
|
11902
|
+
for (const [, query] of queries) {
|
|
11903
|
+
query.removeEventListener("change", onChange);
|
|
11904
|
+
}
|
|
11905
|
+
queries.length = 0;
|
|
11906
|
+
clear(restore);
|
|
11907
|
+
};
|
|
11908
|
+
const runIn = (target, callback) => {
|
|
11909
|
+
const prev = activeScope.current;
|
|
11910
|
+
activeScope.current = target;
|
|
11911
|
+
try {
|
|
11912
|
+
return callback();
|
|
11913
|
+
}
|
|
11914
|
+
finally {
|
|
11915
|
+
activeScope.current = prev;
|
|
11916
|
+
}
|
|
11917
|
+
};
|
|
11918
|
+
const scope = {
|
|
11919
|
+
state: "active",
|
|
11920
|
+
media: {},
|
|
11921
|
+
run: (callback) => runIn(active, callback),
|
|
11922
|
+
ignore: (callback) => runIn(undefined, callback),
|
|
11923
|
+
bind: active.bind,
|
|
11924
|
+
stop: () => kill(),
|
|
11925
|
+
cancel: () => kill(true),
|
|
11926
|
+
refresh() {
|
|
11927
|
+
clear(true);
|
|
11928
|
+
start();
|
|
11929
|
+
},
|
|
11930
|
+
};
|
|
11931
|
+
if (matchMedia && typeof window !== "undefined") {
|
|
11932
|
+
const conditions = typeof matchMedia === "string"
|
|
11933
|
+
? { matches: matchMedia }
|
|
11934
|
+
: matchMedia;
|
|
11935
|
+
for (const name in conditions) {
|
|
11936
|
+
const query = window.matchMedia(toMediaQuery(conditions[name]));
|
|
11937
|
+
query.addEventListener("change", onChange);
|
|
11938
|
+
queries.push([name, query]);
|
|
11939
|
+
}
|
|
11940
|
+
}
|
|
11941
|
+
/**
|
|
11942
|
+
* A scope created inside another is cancelled with it.
|
|
11943
|
+
*/
|
|
11944
|
+
addToScope(scope.cancel);
|
|
11945
|
+
start();
|
|
11946
|
+
return scope;
|
|
11947
|
+
}
|
|
11948
|
+
|
|
11629
11949
|
function clearStatsBuffer() {
|
|
11630
11950
|
statsBuffer.value = null;
|
|
11631
11951
|
statsBuffer.addProjectionMetrics = null;
|
|
@@ -13242,7 +13562,9 @@
|
|
|
13242
13562
|
}
|
|
13243
13563
|
}
|
|
13244
13564
|
function animateView(update, options = {}) {
|
|
13245
|
-
|
|
13565
|
+
const builder = new ViewTransitionBuilder(update, options);
|
|
13566
|
+
addBuilderToScope(builder);
|
|
13567
|
+
return builder;
|
|
13246
13568
|
}
|
|
13247
13569
|
|
|
13248
13570
|
/**
|
|
@@ -13536,8 +13858,7 @@
|
|
|
13536
13858
|
const valueHasChanged = Array.isArray(next) && Array.isArray(prev)
|
|
13537
13859
|
? !shallowCompare(next, prev) || variantDidChange
|
|
13538
13860
|
: next !== prev;
|
|
13539
|
-
if (valueHasChanged &&
|
|
13540
|
-
(next === undefined || next === null)) {
|
|
13861
|
+
if (valueHasChanged && (next === undefined || next === null)) {
|
|
13541
13862
|
removedKeys.add(key);
|
|
13542
13863
|
}
|
|
13543
13864
|
else if (valueHasChanged ||
|
|
@@ -13751,7 +14072,12 @@
|
|
|
13751
14072
|
*/
|
|
13752
14073
|
function animateLayout(scopeOrUpdateDom, updateDomOrOptions, options) {
|
|
13753
14074
|
const { scope, updateDom, defaultOptions } = parseAnimateLayoutArgs(scopeOrUpdateDom, updateDomOrOptions, options);
|
|
13754
|
-
|
|
14075
|
+
const builder = new LayoutAnimationBuilder(scope, updateDom, {
|
|
14076
|
+
...activeScope.current?.transition,
|
|
14077
|
+
...defaultOptions,
|
|
14078
|
+
});
|
|
14079
|
+
addBuilderToScope(builder);
|
|
14080
|
+
return builder;
|
|
13755
14081
|
}
|
|
13756
14082
|
|
|
13757
14083
|
/**
|
|
@@ -13796,7 +14122,9 @@
|
|
|
13796
14122
|
exports.VisualElement = VisualElement;
|
|
13797
14123
|
exports.VisualElementDragControls = VisualElementDragControls;
|
|
13798
14124
|
exports.acceleratedValues = acceleratedValues;
|
|
14125
|
+
exports.activeScope = activeScope;
|
|
13799
14126
|
exports.addAttrValue = addAttrValue;
|
|
14127
|
+
exports.addBuilderToScope = addBuilderToScope;
|
|
13800
14128
|
exports.addDomEvent = addDomEvent;
|
|
13801
14129
|
exports.addEffect = addEffect;
|
|
13802
14130
|
exports.addPointerEvent = addPointerEvent;
|
|
@@ -13804,6 +14132,7 @@
|
|
|
13804
14132
|
exports.addSVGValue = addSVGValue;
|
|
13805
14133
|
exports.addScaleCorrector = addScaleCorrector;
|
|
13806
14134
|
exports.addStyleValue = addStyleValue;
|
|
14135
|
+
exports.addToScope = addToScope;
|
|
13807
14136
|
exports.addValueToWillChange = addValueToWillChange;
|
|
13808
14137
|
exports.alpha = alpha;
|
|
13809
14138
|
exports.analyseComplexValue = analyseComplexValue;
|
|
@@ -13833,6 +14162,7 @@
|
|
|
13833
14162
|
exports.axisDeltaEquals = axisDeltaEquals;
|
|
13834
14163
|
exports.axisEquals = axisEquals;
|
|
13835
14164
|
exports.axisEqualsRounded = axisEqualsRounded;
|
|
14165
|
+
exports.bindToScope = bindToScope;
|
|
13836
14166
|
exports.boxEquals = boxEquals;
|
|
13837
14167
|
exports.boxEqualsRounded = boxEqualsRounded;
|
|
13838
14168
|
exports.buildHTMLStyles = buildHTMLStyles;
|
|
@@ -13994,6 +14324,7 @@
|
|
|
13994
14324
|
exports.positionalKeys = positionalKeys;
|
|
13995
14325
|
exports.prefersReducedMotion = prefersReducedMotion;
|
|
13996
14326
|
exports.press = press;
|
|
14327
|
+
exports.processFrame = processFrame;
|
|
13997
14328
|
exports.progressPercentage = progressPercentage;
|
|
13998
14329
|
exports.propEffect = propEffect;
|
|
13999
14330
|
exports.propagateDirtyNodes = propagateDirtyNodes;
|
|
@@ -14002,6 +14333,7 @@
|
|
|
14002
14333
|
exports.readStyleValue = readStyleValue;
|
|
14003
14334
|
exports.readTransformValue = readTransformValue;
|
|
14004
14335
|
exports.recordStats = recordStats;
|
|
14336
|
+
exports.releaseElement = releaseElement;
|
|
14005
14337
|
exports.removeAxisDelta = removeAxisDelta;
|
|
14006
14338
|
exports.removeAxisTransforms = removeAxisTransforms;
|
|
14007
14339
|
exports.removeBoxTransforms = removeBoxTransforms;
|
|
@@ -14023,6 +14355,7 @@
|
|
|
14023
14355
|
exports.scale = scale;
|
|
14024
14356
|
exports.scaleCorrectors = scaleCorrectors;
|
|
14025
14357
|
exports.scalePoint = scalePoint;
|
|
14358
|
+
exports.scopeMotion = scopeMotion;
|
|
14026
14359
|
exports.scrapeHTMLMotionValuesFromProps = scrapeMotionValuesFromProps$1;
|
|
14027
14360
|
exports.scrapeSVGMotionValuesFromProps = scrapeMotionValuesFromProps;
|
|
14028
14361
|
exports.setDragLock = setDragLock;
|
|
@@ -14049,6 +14382,7 @@
|
|
|
14049
14382
|
exports.sync = sync;
|
|
14050
14383
|
exports.testValueType = testValueType;
|
|
14051
14384
|
exports.time = time;
|
|
14385
|
+
exports.toMediaQuery = toMediaQuery;
|
|
14052
14386
|
exports.transform = transform;
|
|
14053
14387
|
exports.transformAxis = transformAxis;
|
|
14054
14388
|
exports.transformBox = transformBox;
|