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/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];
|
|
@@ -5830,6 +5855,43 @@ function isSVGElement(element) {
|
|
|
5830
5855
|
return motionUtils.isObject(element) && "ownerSVGElement" in element;
|
|
5831
5856
|
}
|
|
5832
5857
|
|
|
5858
|
+
const activeScope = {};
|
|
5859
|
+
/**
|
|
5860
|
+
* Register `cleanup` with the active scope, if there is one, so stopping
|
|
5861
|
+
* the scope also runs it.
|
|
5862
|
+
*/
|
|
5863
|
+
function addToScope(cleanup) {
|
|
5864
|
+
activeScope.current?.add(cleanup);
|
|
5865
|
+
return cleanup;
|
|
5866
|
+
}
|
|
5867
|
+
/**
|
|
5868
|
+
* Collect the animation a builder like `animateLayout()` or
|
|
5869
|
+
* `animateView()` resolves with. If the scope stops first, the animation
|
|
5870
|
+
* is stopped as soon as it starts.
|
|
5871
|
+
*/
|
|
5872
|
+
function addBuilderToScope(builder) {
|
|
5873
|
+
const scope = activeScope.current;
|
|
5874
|
+
if (!scope)
|
|
5875
|
+
return;
|
|
5876
|
+
let isStopped = false;
|
|
5877
|
+
let stop;
|
|
5878
|
+
const remove = scope.add(() => {
|
|
5879
|
+
isStopped = true;
|
|
5880
|
+
stop?.();
|
|
5881
|
+
});
|
|
5882
|
+
builder.then((animation) => {
|
|
5883
|
+
if (!animation)
|
|
5884
|
+
return;
|
|
5885
|
+
stop = () => animation.stop();
|
|
5886
|
+
isStopped ? stop() : animation.finished.then(remove);
|
|
5887
|
+
}, remove);
|
|
5888
|
+
}
|
|
5889
|
+
/**
|
|
5890
|
+
* Bind `callback` to the active scope, so anything it starts later (for
|
|
5891
|
+
* instance an animation in an `inView()` callback) is collected too.
|
|
5892
|
+
*/
|
|
5893
|
+
const bindToScope = (callback) => activeScope.current ? activeScope.current.bind(callback) : callback;
|
|
5894
|
+
|
|
5833
5895
|
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
5834
5896
|
if (elementOrSelector == null) {
|
|
5835
5897
|
return [];
|
|
@@ -5838,10 +5900,9 @@ function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
|
5838
5900
|
return [elementOrSelector];
|
|
5839
5901
|
}
|
|
5840
5902
|
else if (typeof elementOrSelector === "string") {
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
root
|
|
5844
|
-
}
|
|
5903
|
+
const root = scope
|
|
5904
|
+
? scope.current
|
|
5905
|
+
: activeScope.current?.root || document;
|
|
5845
5906
|
const elements = selectorCache?.[elementOrSelector] ??
|
|
5846
5907
|
root.querySelectorAll(elementOrSelector);
|
|
5847
5908
|
return elements ? Array.from(elements) : [];
|
|
@@ -6127,6 +6188,10 @@ const styleSubjectEffect = /*@__PURE__*/ createEffect(addStyleValue, {
|
|
|
6127
6188
|
const styleEffect =
|
|
6128
6189
|
/*@__PURE__*/ createSelectorEffect(styleSubjectEffect);
|
|
6129
6190
|
|
|
6191
|
+
function camelToDash(str) {
|
|
6192
|
+
return str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
|
|
6193
|
+
}
|
|
6194
|
+
|
|
6130
6195
|
function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
6131
6196
|
const { style, vars, transformOrigin } = state;
|
|
6132
6197
|
// Track whether we encounter any transform or transformOrigin values.
|
|
@@ -6631,12 +6696,20 @@ class EffectSubject {
|
|
|
6631
6696
|
* sharing values and a renderer.
|
|
6632
6697
|
*/
|
|
6633
6698
|
function animateElement(element, keyframes, transition, visualElement) {
|
|
6699
|
+
activeScope.current?.track(element);
|
|
6634
6700
|
if (visualElement) {
|
|
6635
6701
|
return animateValues((key) => visualElement.getValue(key, null), keyframes, transition, visualElement);
|
|
6636
6702
|
}
|
|
6637
6703
|
const effect = getElementEffect(element);
|
|
6638
6704
|
return animateEffectSubject(effect, element, keyframes, transition, new EffectSubject(effect, element));
|
|
6639
6705
|
}
|
|
6706
|
+
/**
|
|
6707
|
+
* Detach the values styleEffect/svgEffect bound to `element`, so the
|
|
6708
|
+
* next animation reads its starting values from the DOM again.
|
|
6709
|
+
*/
|
|
6710
|
+
const releaseElement = (element) => getElementEffect(element)
|
|
6711
|
+
.state(element)
|
|
6712
|
+
?.release();
|
|
6640
6713
|
/**
|
|
6641
6714
|
* Hand the values styleEffect/svgEffect are rendering on `element`,
|
|
6642
6715
|
* whether bound by animate() or directly, to a VisualElement that now
|
|
@@ -6694,6 +6767,41 @@ const propEffect = /*@__PURE__*/ createEffect((subject, state, key, value) => {
|
|
|
6694
6767
|
const { schedule: microtask, cancel: cancelMicrotask } =
|
|
6695
6768
|
/* @__PURE__ */ createRenderBatcher(queueMicrotask, false);
|
|
6696
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
|
+
|
|
6697
6805
|
function animateSingleValue(value, keyframes, options) {
|
|
6698
6806
|
const motionValue$1 = isMotionValue(value) ? value : motionValue(value);
|
|
6699
6807
|
motionValue$1.start(animateMotionValue("", motionValue$1, keyframes, options));
|
|
@@ -6727,6 +6835,7 @@ const statsBuffer = {
|
|
|
6727
6835
|
*/
|
|
6728
6836
|
function delay(callback, timeout) {
|
|
6729
6837
|
const start = time.now();
|
|
6838
|
+
callback = bindToScope(callback);
|
|
6730
6839
|
const checkElapsed = ({ timestamp }) => {
|
|
6731
6840
|
const elapsed = timestamp - start;
|
|
6732
6841
|
if (elapsed >= timeout) {
|
|
@@ -6735,7 +6844,7 @@ function delay(callback, timeout) {
|
|
|
6735
6844
|
}
|
|
6736
6845
|
};
|
|
6737
6846
|
frame.setup(checkElapsed, true);
|
|
6738
|
-
return () => cancelFrame(checkElapsed);
|
|
6847
|
+
return addToScope(() => cancelFrame(checkElapsed));
|
|
6739
6848
|
}
|
|
6740
6849
|
function delayInSeconds(callback, timeout) {
|
|
6741
6850
|
return delay(callback, motionUtils.secondsToMilliseconds(timeout));
|
|
@@ -7159,10 +7268,9 @@ const correctBoxShadow = {
|
|
|
7159
7268
|
};
|
|
7160
7269
|
|
|
7161
7270
|
const defaultScaleCorrectors = {
|
|
7162
|
-
borderRadius: {
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
},
|
|
7271
|
+
borderRadius: /* @__PURE__ */ Object.assign({}, correctBorderRadius, {
|
|
7272
|
+
applyTo: /* @__PURE__ */ cornerRadiusProps.slice(),
|
|
7273
|
+
}),
|
|
7166
7274
|
borderTopLeftRadius: correctBorderRadius,
|
|
7167
7275
|
borderTopRightRadius: correctBorderRadius,
|
|
7168
7276
|
borderBottomLeftRadius: correctBorderRadius,
|
|
@@ -7267,14 +7375,6 @@ const globalProjectionState = {
|
|
|
7267
7375
|
hasEverUpdated: false,
|
|
7268
7376
|
};
|
|
7269
7377
|
|
|
7270
|
-
/**
|
|
7271
|
-
* Correctors registered via addScaleCorrector before projection loaded
|
|
7272
|
-
* (e.g. with an async LazyMotion bundle) take precedence over the defaults.
|
|
7273
|
-
*/
|
|
7274
|
-
Object.assign(scaleCorrectors, {
|
|
7275
|
-
...defaultScaleCorrectors,
|
|
7276
|
-
...scaleCorrectors,
|
|
7277
|
-
});
|
|
7278
7378
|
const metrics = {
|
|
7279
7379
|
nodes: 0,
|
|
7280
7380
|
calculatedTargetDeltas: 0,
|
|
@@ -7317,6 +7417,16 @@ function cancelTreeOptimisedTransformAnimations(projectionNode) {
|
|
|
7317
7417
|
}
|
|
7318
7418
|
}
|
|
7319
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
|
+
});
|
|
7320
7430
|
return class ProjectionNode {
|
|
7321
7431
|
constructor(latestValues = {}, parent = defaultParent?.()) {
|
|
7322
7432
|
/**
|
|
@@ -7973,7 +8083,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
7973
8083
|
}
|
|
7974
8084
|
return boxWithoutScroll;
|
|
7975
8085
|
}
|
|
7976
|
-
applyTransform(box, transformOnly = false, output) {
|
|
8086
|
+
applyTransform(box, transformOnly = false, output, skipOwnTransform) {
|
|
7977
8087
|
const withTransforms = output || createBox();
|
|
7978
8088
|
copyBoxInto(withTransforms, box);
|
|
7979
8089
|
for (let i = 0; i < this.path.length; i++) {
|
|
@@ -7989,7 +8099,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
7989
8099
|
continue;
|
|
7990
8100
|
transformBox(withTransforms, node.latestValues, node.layout?.layoutBox);
|
|
7991
8101
|
}
|
|
7992
|
-
if (hasTransform(this.latestValues)) {
|
|
8102
|
+
if (!skipOwnTransform && hasTransform(this.latestValues)) {
|
|
7993
8103
|
transformBox(withTransforms, this.latestValues, this.layout?.layoutBox);
|
|
7994
8104
|
}
|
|
7995
8105
|
return withTransforms;
|
|
@@ -8124,7 +8234,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
8124
8234
|
}
|
|
8125
8235
|
else if (this.targetDelta) {
|
|
8126
8236
|
if (Boolean(this.resumingFrom)) {
|
|
8127
|
-
|
|
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);
|
|
8128
8242
|
}
|
|
8129
8243
|
else {
|
|
8130
8244
|
copyBoxInto(this.target, this.layout.layoutBox);
|
|
@@ -8893,10 +9007,13 @@ function clearIsLayoutDirty(node) {
|
|
|
8893
9007
|
* A dragged node doesn't layout animate, so it jumps to its new layout. Shift
|
|
8894
9008
|
* its descendants' snapshots by the same amount, so they only animate layout
|
|
8895
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.
|
|
8896
9013
|
*/
|
|
8897
9014
|
function followDraggedAncestor(node) {
|
|
8898
9015
|
const { snapshot, dragAncestor } = node;
|
|
8899
|
-
const to = dragAncestor?.layout;
|
|
9016
|
+
const to = dragAncestor?.isAnimationBlocked && dragAncestor.layout;
|
|
8900
9017
|
if (!snapshot || !to || node.resumeFrom || node.isAnimationBlocked)
|
|
8901
9018
|
return;
|
|
8902
9019
|
const from = dragAncestor.dragSnapshot;
|
|
@@ -9010,11 +9127,16 @@ function addDomEvent(target, eventName, handler, options = { passive: true }) {
|
|
|
9010
9127
|
return () => target.removeEventListener(eventName, handler, options);
|
|
9011
9128
|
}
|
|
9012
9129
|
|
|
9013
|
-
const DocumentProjectionNode =
|
|
9130
|
+
const DocumentProjectionNode =
|
|
9131
|
+
/* @__PURE__ */ createProjectionNode({
|
|
9014
9132
|
attachResizeListener: (ref, notify) => addDomEvent(ref, "resize", notify),
|
|
9015
9133
|
measureScroll: () => ({
|
|
9016
|
-
x: document.documentElement.scrollLeft ||
|
|
9017
|
-
|
|
9134
|
+
x: document.documentElement.scrollLeft ||
|
|
9135
|
+
document.body?.scrollLeft ||
|
|
9136
|
+
0,
|
|
9137
|
+
y: document.documentElement.scrollTop ||
|
|
9138
|
+
document.body?.scrollTop ||
|
|
9139
|
+
0,
|
|
9018
9140
|
}),
|
|
9019
9141
|
checkIsScrollRoot: () => true,
|
|
9020
9142
|
});
|
|
@@ -9022,7 +9144,9 @@ const DocumentProjectionNode = createProjectionNode({
|
|
|
9022
9144
|
const rootProjectionNode = {
|
|
9023
9145
|
current: undefined,
|
|
9024
9146
|
};
|
|
9025
|
-
|
|
9147
|
+
|
|
9148
|
+
const HTMLProjectionNode =
|
|
9149
|
+
/* @__PURE__ */ createProjectionNode({
|
|
9026
9150
|
measureScroll: (instance) => ({
|
|
9027
9151
|
x: instance.scrollLeft,
|
|
9028
9152
|
y: instance.scrollTop,
|
|
@@ -9066,7 +9190,7 @@ const variantPriorityOrder = [
|
|
|
9066
9190
|
"whileDrag",
|
|
9067
9191
|
"exit",
|
|
9068
9192
|
];
|
|
9069
|
-
const variantProps = ["initial"
|
|
9193
|
+
const variantProps = /* @__PURE__ */ ["initial"].concat(variantPriorityOrder);
|
|
9070
9194
|
|
|
9071
9195
|
function isControllingVariants(props) {
|
|
9072
9196
|
if (isAnimationControls(props.animate))
|
|
@@ -10149,7 +10273,7 @@ class LayoutAnimationBuilder {
|
|
|
10149
10273
|
function parseAnimateLayoutArgs(scopeOrUpdateDom, updateDomOrOptions, options) {
|
|
10150
10274
|
if (typeof scopeOrUpdateDom === "function") {
|
|
10151
10275
|
return {
|
|
10152
|
-
scope: document,
|
|
10276
|
+
scope: activeScope.current?.root || document,
|
|
10153
10277
|
updateDom: scopeOrUpdateDom,
|
|
10154
10278
|
defaultOptions: updateDomOrOptions,
|
|
10155
10279
|
};
|
|
@@ -10285,7 +10409,7 @@ function resizeWindow(callback) {
|
|
|
10285
10409
|
}
|
|
10286
10410
|
|
|
10287
10411
|
function resize(a, b) {
|
|
10288
|
-
return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
|
|
10412
|
+
return addToScope(typeof a === "function" ? resizeWindow(a) : resizeElement(a, b));
|
|
10289
10413
|
}
|
|
10290
10414
|
|
|
10291
10415
|
const distance = (a, b) => Math.abs(a - b);
|
|
@@ -10350,6 +10474,12 @@ class PanSession {
|
|
|
10350
10474
|
onMove && onMove(this.lastMoveEvent, info);
|
|
10351
10475
|
};
|
|
10352
10476
|
this.handlePointerMove = (event, info) => {
|
|
10477
|
+
/**
|
|
10478
|
+
* This event's pageX/pageY already include any window scroll that
|
|
10479
|
+
* hasn't fired its scroll event yet. Settle it now, so that scroll
|
|
10480
|
+
* event doesn't add it to the new point a second time.
|
|
10481
|
+
*/
|
|
10482
|
+
this.handleScroll(window);
|
|
10353
10483
|
this.lastMoveEvent = event;
|
|
10354
10484
|
this.lastRawMoveEventInfo = info;
|
|
10355
10485
|
this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint);
|
|
@@ -10906,7 +11036,11 @@ class VisualElementDragControls {
|
|
|
10906
11036
|
element: this.visualElement.current,
|
|
10907
11037
|
});
|
|
10908
11038
|
}
|
|
10909
|
-
|
|
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) {
|
|
10910
11044
|
const finalEvent = event || this.latestPointerEvent;
|
|
10911
11045
|
const finalPanInfo = panInfo || this.latestPanInfo;
|
|
10912
11046
|
const isDragging = this.isDragging;
|
|
@@ -10914,7 +11048,7 @@ class VisualElementDragControls {
|
|
|
10914
11048
|
if (!isDragging || !finalPanInfo || !finalEvent)
|
|
10915
11049
|
return;
|
|
10916
11050
|
const { velocity } = finalPanInfo;
|
|
10917
|
-
this.startAnimation(velocity);
|
|
11051
|
+
this.startAnimation(velocity, dragAxes);
|
|
10918
11052
|
const { onDragEnd } = this.getProps();
|
|
10919
11053
|
if (onDragEnd) {
|
|
10920
11054
|
frame.postRender(() => onDragEnd(finalEvent, finalPanInfo));
|
|
@@ -11035,11 +11169,11 @@ class VisualElementDragControls {
|
|
|
11035
11169
|
}
|
|
11036
11170
|
return measuredConstraints;
|
|
11037
11171
|
}
|
|
11038
|
-
startAnimation(velocity) {
|
|
11172
|
+
startAnimation(velocity, dragAxes) {
|
|
11039
11173
|
const { drag, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd, } = this.getProps();
|
|
11040
11174
|
const constraints = this.constraints || {};
|
|
11041
11175
|
const momentumAnimations = eachAxis((axis) => {
|
|
11042
|
-
if (!shouldDrag(axis, drag, this.currentDirection)) {
|
|
11176
|
+
if (!shouldDrag(axis, dragAxes || drag, this.currentDirection)) {
|
|
11043
11177
|
return;
|
|
11044
11178
|
}
|
|
11045
11179
|
let transition = (constraints && constraints[axis]) || {};
|
|
@@ -11242,9 +11376,15 @@ class VisualElementDragControls {
|
|
|
11242
11376
|
const stopLayoutUpdateListener = projection.addEventListener("didUpdate", (({ delta, hasLayoutChanged }) => {
|
|
11243
11377
|
if (this.isDragging && hasLayoutChanged) {
|
|
11244
11378
|
eachAxis((axis) => {
|
|
11245
|
-
|
|
11246
|
-
|
|
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))
|
|
11247
11386
|
return;
|
|
11387
|
+
const motionValue = this.getAxisMotionValue(axis);
|
|
11248
11388
|
this.originPoint[axis] += delta[axis].translate;
|
|
11249
11389
|
motionValue.set(motionValue.get() + delta[axis].translate);
|
|
11250
11390
|
});
|
|
@@ -11381,7 +11521,20 @@ function applyDragStyles(element, axis) {
|
|
|
11381
11521
|
*/
|
|
11382
11522
|
function drag(elementOrSelector, options = {}) {
|
|
11383
11523
|
const props = toProps(options);
|
|
11524
|
+
const scope = activeScope.current;
|
|
11525
|
+
/**
|
|
11526
|
+
* Run callbacks in the active scope, so work they start is collected.
|
|
11527
|
+
*/
|
|
11528
|
+
if (scope) {
|
|
11529
|
+
for (const key in props) {
|
|
11530
|
+
const value = props[key];
|
|
11531
|
+
if (typeof value === "function") {
|
|
11532
|
+
props[key] = scope.bind(value);
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11535
|
+
}
|
|
11384
11536
|
const cleanups = resolveElements(elementOrSelector).map((element) => {
|
|
11537
|
+
scope?.track(element);
|
|
11385
11538
|
const [node, release] = acquireProjectionNode(element);
|
|
11386
11539
|
/**
|
|
11387
11540
|
* Measure layout even when not animating it, as constraints and
|
|
@@ -11395,10 +11548,11 @@ function drag(elementOrSelector, options = {}) {
|
|
|
11395
11548
|
removeStyles();
|
|
11396
11549
|
removeListeners?.();
|
|
11397
11550
|
controls.cancel();
|
|
11551
|
+
controls.stopAnimation();
|
|
11398
11552
|
release();
|
|
11399
11553
|
};
|
|
11400
11554
|
});
|
|
11401
|
-
return () => cleanups.forEach((cleanup) => cleanup());
|
|
11555
|
+
return addToScope(() => cleanups.forEach((cleanup) => cleanup()));
|
|
11402
11556
|
}
|
|
11403
11557
|
|
|
11404
11558
|
function setupGesture(elementOrSelector, options) {
|
|
@@ -11409,7 +11563,7 @@ function setupGesture(elementOrSelector, options) {
|
|
|
11409
11563
|
...options,
|
|
11410
11564
|
signal: gestureAbortController.signal,
|
|
11411
11565
|
};
|
|
11412
|
-
const cancel = () => gestureAbortController.abort();
|
|
11566
|
+
const cancel = addToScope(() => gestureAbortController.abort());
|
|
11413
11567
|
return [elements, eventOptions, cancel];
|
|
11414
11568
|
}
|
|
11415
11569
|
|
|
@@ -11424,6 +11578,7 @@ function isValidHover(event) {
|
|
|
11424
11578
|
* @public
|
|
11425
11579
|
*/
|
|
11426
11580
|
function hover(elementOrSelector, onHoverStart, options = {}) {
|
|
11581
|
+
onHoverStart = bindToScope(onHoverStart);
|
|
11427
11582
|
const [elements, eventOptions, cancel] = setupGesture(elementOrSelector, options);
|
|
11428
11583
|
elements.forEach((element) => {
|
|
11429
11584
|
let isPressed = false;
|
|
@@ -11512,26 +11667,36 @@ function filterEvents(callback) {
|
|
|
11512
11667
|
function firePointerEvent(target, type) {
|
|
11513
11668
|
target.dispatchEvent(new PointerEvent("pointer" + type, { isPrimary: true, bubbles: true }));
|
|
11514
11669
|
}
|
|
11515
|
-
const enableKeyboardPress = (
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11670
|
+
const enableKeyboardPress = (element, eventOptions) => {
|
|
11671
|
+
/**
|
|
11672
|
+
* Listeners are scoped to this focus and all released on blur, rather
|
|
11673
|
+
* than added per Enter press, so they can't accumulate and fire
|
|
11674
|
+
* duplicate pointerup/pointercancel events. See #3935.
|
|
11675
|
+
*/
|
|
11676
|
+
let isKeyPressing = false;
|
|
11519
11677
|
const handleKeydown = filterEvents(() => {
|
|
11520
11678
|
if (isPressing.has(element))
|
|
11521
11679
|
return;
|
|
11680
|
+
isKeyPressing = true;
|
|
11522
11681
|
firePointerEvent(element, "down");
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
element
|
|
11682
|
+
});
|
|
11683
|
+
const handleKeyup = filterEvents(() => {
|
|
11684
|
+
if (!isKeyPressing)
|
|
11685
|
+
return;
|
|
11686
|
+
isKeyPressing = false;
|
|
11687
|
+
firePointerEvent(element, "up");
|
|
11529
11688
|
});
|
|
11530
11689
|
element.addEventListener("keydown", handleKeydown, eventOptions);
|
|
11690
|
+
element.addEventListener("keyup", handleKeyup, eventOptions);
|
|
11531
11691
|
/**
|
|
11532
|
-
*
|
|
11692
|
+
* On blur, remove the key listeners and cancel any keyboard press.
|
|
11533
11693
|
*/
|
|
11534
|
-
element.addEventListener("blur", () =>
|
|
11694
|
+
element.addEventListener("blur", () => {
|
|
11695
|
+
element.removeEventListener("keydown", handleKeydown);
|
|
11696
|
+
element.removeEventListener("keyup", handleKeyup);
|
|
11697
|
+
if (isKeyPressing)
|
|
11698
|
+
firePointerEvent(element, "cancel");
|
|
11699
|
+
}, { ...eventOptions, once: true });
|
|
11535
11700
|
};
|
|
11536
11701
|
|
|
11537
11702
|
/**
|
|
@@ -11562,6 +11727,7 @@ const claimedPointerDownEvents = new WeakSet();
|
|
|
11562
11727
|
* @public
|
|
11563
11728
|
*/
|
|
11564
11729
|
function press(targetOrSelector, onPressStart, options = {}) {
|
|
11730
|
+
onPressStart = bindToScope(onPressStart);
|
|
11565
11731
|
const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
|
|
11566
11732
|
const startPress = (startEvent) => {
|
|
11567
11733
|
const target = startEvent.currentTarget;
|
|
@@ -11610,7 +11776,7 @@ function press(targetOrSelector, onPressStart, options = {}) {
|
|
|
11610
11776
|
const pointerDownTarget = options.useGlobalTarget ? window : target;
|
|
11611
11777
|
pointerDownTarget.addEventListener("pointerdown", startPress, eventOptions);
|
|
11612
11778
|
if (isHTMLElement(target)) {
|
|
11613
|
-
target.addEventListener("focus", (
|
|
11779
|
+
target.addEventListener("focus", () => enableKeyboardPress(target, eventOptions), eventOptions);
|
|
11614
11780
|
if (!isElementKeyboardAccessible(target) &&
|
|
11615
11781
|
!target.hasAttribute("tabindex")) {
|
|
11616
11782
|
target.tabIndex = 0;
|
|
@@ -11627,6 +11793,160 @@ function getComputedStyle$1(element, name) {
|
|
|
11627
11793
|
: computedStyle[name];
|
|
11628
11794
|
}
|
|
11629
11795
|
|
|
11796
|
+
const keywords = {
|
|
11797
|
+
reducedMotion: "(prefers-reduced-motion: reduce)",
|
|
11798
|
+
motion: "(prefers-reduced-motion: no-preference)",
|
|
11799
|
+
dark: "(prefers-color-scheme: dark)",
|
|
11800
|
+
light: "(prefers-color-scheme: light)",
|
|
11801
|
+
hover: "(hover: hover) and (pointer: fine)",
|
|
11802
|
+
touch: "(pointer: coarse)",
|
|
11803
|
+
portrait: "(orientation: portrait)",
|
|
11804
|
+
landscape: "(orientation: landscape)",
|
|
11805
|
+
};
|
|
11806
|
+
/**
|
|
11807
|
+
* Turn a condition into a media query. Full media queries pass through
|
|
11808
|
+
* unchanged. Otherwise each space-separated token must match:
|
|
11809
|
+
*
|
|
11810
|
+
* - A width comparison: `">=800"`, `"<1200px"`, `"> 40em"`
|
|
11811
|
+
* - A keyword: `reducedMotion`, `motion`, `dark`, `light`, `hover`,
|
|
11812
|
+
* `touch`, `portrait`, `landscape`
|
|
11813
|
+
*
|
|
11814
|
+
* Prefix a token with `!` to negate it, for instance `">=800 !touch"`.
|
|
11815
|
+
*/
|
|
11816
|
+
function toMediaQuery(condition) {
|
|
11817
|
+
if (condition.includes("("))
|
|
11818
|
+
return condition;
|
|
11819
|
+
return condition
|
|
11820
|
+
.replace(/([<>!]=?)\s+/g, "$1")
|
|
11821
|
+
.trim()
|
|
11822
|
+
.split(/\s+/)
|
|
11823
|
+
.map((token) => {
|
|
11824
|
+
const isNot = token[0] === "!";
|
|
11825
|
+
if (isNot)
|
|
11826
|
+
token = token.slice(1);
|
|
11827
|
+
const width = /^([<>]=?)([\d.]+)([a-z]*)$/.exec(token);
|
|
11828
|
+
const query = width
|
|
11829
|
+
? `(width ${width[1]} ${width[2]}${width[3] || "px"})`
|
|
11830
|
+
: keywords[token] || token;
|
|
11831
|
+
return isNot ? `(not (${query}))` : query;
|
|
11832
|
+
})
|
|
11833
|
+
.join(" and ");
|
|
11834
|
+
}
|
|
11835
|
+
|
|
11836
|
+
function scopeMotion(...args) {
|
|
11837
|
+
const root = typeof args[0] === "function" ? undefined : args.shift();
|
|
11838
|
+
const [setup, options = {}] = args;
|
|
11839
|
+
const { transition, matchMedia } = options;
|
|
11840
|
+
const queries = [];
|
|
11841
|
+
const styles = new Map();
|
|
11842
|
+
let cleanups = [];
|
|
11843
|
+
let isPending = false;
|
|
11844
|
+
const active = {
|
|
11845
|
+
root: resolveElements(root)[0],
|
|
11846
|
+
transition,
|
|
11847
|
+
add(cleanup) {
|
|
11848
|
+
cleanups.push(cleanup);
|
|
11849
|
+
return () => motionUtils.removeItem(cleanups, cleanup);
|
|
11850
|
+
},
|
|
11851
|
+
bind: (callback) => ((...args) => {
|
|
11852
|
+
const result = scope.run(() => callback(...args));
|
|
11853
|
+
return typeof result === "function"
|
|
11854
|
+
? active.bind(result)
|
|
11855
|
+
: result;
|
|
11856
|
+
}),
|
|
11857
|
+
track(element) {
|
|
11858
|
+
styles.has(element) ||
|
|
11859
|
+
styles.set(element, element.getAttribute("style"));
|
|
11860
|
+
},
|
|
11861
|
+
};
|
|
11862
|
+
const clear = (restore) => {
|
|
11863
|
+
const current = cleanups;
|
|
11864
|
+
cleanups = [];
|
|
11865
|
+
for (let i = current.length - 1; i >= 0; i--)
|
|
11866
|
+
current[i]();
|
|
11867
|
+
restore &&
|
|
11868
|
+
styles.forEach((style, element) => {
|
|
11869
|
+
releaseElement(element);
|
|
11870
|
+
style === null
|
|
11871
|
+
? element.removeAttribute("style")
|
|
11872
|
+
: element.setAttribute("style", style);
|
|
11873
|
+
});
|
|
11874
|
+
styles.clear();
|
|
11875
|
+
};
|
|
11876
|
+
const start = () => {
|
|
11877
|
+
scope.state = "active";
|
|
11878
|
+
let matches = !queries.length;
|
|
11879
|
+
scope.media = {};
|
|
11880
|
+
for (const [name, query] of queries) {
|
|
11881
|
+
matches = (scope.media[name] = query.matches) || matches;
|
|
11882
|
+
}
|
|
11883
|
+
if (matches && setup) {
|
|
11884
|
+
const cleanup = scope.run(() => setup(scope));
|
|
11885
|
+
typeof cleanup === "function" && active.add(cleanup);
|
|
11886
|
+
}
|
|
11887
|
+
};
|
|
11888
|
+
const onChange = () => {
|
|
11889
|
+
if (isPending)
|
|
11890
|
+
return;
|
|
11891
|
+
isPending = true;
|
|
11892
|
+
/**
|
|
11893
|
+
* Several conditions can change together, for instance two
|
|
11894
|
+
* breakpoints crossed by one resize. Refresh once.
|
|
11895
|
+
*/
|
|
11896
|
+
queueMicrotask(() => {
|
|
11897
|
+
isPending = false;
|
|
11898
|
+
queries.length && scope.refresh();
|
|
11899
|
+
});
|
|
11900
|
+
};
|
|
11901
|
+
const kill = (restore) => {
|
|
11902
|
+
scope.state = restore ? "cancelled" : "stopped";
|
|
11903
|
+
for (const [, query] of queries) {
|
|
11904
|
+
query.removeEventListener("change", onChange);
|
|
11905
|
+
}
|
|
11906
|
+
queries.length = 0;
|
|
11907
|
+
clear(restore);
|
|
11908
|
+
};
|
|
11909
|
+
const runIn = (target, callback) => {
|
|
11910
|
+
const prev = activeScope.current;
|
|
11911
|
+
activeScope.current = target;
|
|
11912
|
+
try {
|
|
11913
|
+
return callback();
|
|
11914
|
+
}
|
|
11915
|
+
finally {
|
|
11916
|
+
activeScope.current = prev;
|
|
11917
|
+
}
|
|
11918
|
+
};
|
|
11919
|
+
const scope = {
|
|
11920
|
+
state: "active",
|
|
11921
|
+
media: {},
|
|
11922
|
+
run: (callback) => runIn(active, callback),
|
|
11923
|
+
ignore: (callback) => runIn(undefined, callback),
|
|
11924
|
+
bind: active.bind,
|
|
11925
|
+
stop: () => kill(),
|
|
11926
|
+
cancel: () => kill(true),
|
|
11927
|
+
refresh() {
|
|
11928
|
+
clear(true);
|
|
11929
|
+
start();
|
|
11930
|
+
},
|
|
11931
|
+
};
|
|
11932
|
+
if (matchMedia && typeof window !== "undefined") {
|
|
11933
|
+
const conditions = typeof matchMedia === "string"
|
|
11934
|
+
? { matches: matchMedia }
|
|
11935
|
+
: matchMedia;
|
|
11936
|
+
for (const name in conditions) {
|
|
11937
|
+
const query = window.matchMedia(toMediaQuery(conditions[name]));
|
|
11938
|
+
query.addEventListener("change", onChange);
|
|
11939
|
+
queries.push([name, query]);
|
|
11940
|
+
}
|
|
11941
|
+
}
|
|
11942
|
+
/**
|
|
11943
|
+
* A scope created inside another is cancelled with it.
|
|
11944
|
+
*/
|
|
11945
|
+
addToScope(scope.cancel);
|
|
11946
|
+
start();
|
|
11947
|
+
return scope;
|
|
11948
|
+
}
|
|
11949
|
+
|
|
11630
11950
|
function clearStatsBuffer() {
|
|
11631
11951
|
statsBuffer.value = null;
|
|
11632
11952
|
statsBuffer.addProjectionMetrics = null;
|
|
@@ -13243,7 +13563,9 @@ class ViewTransitionBuilder {
|
|
|
13243
13563
|
}
|
|
13244
13564
|
}
|
|
13245
13565
|
function animateView(update, options = {}) {
|
|
13246
|
-
|
|
13566
|
+
const builder = new ViewTransitionBuilder(update, options);
|
|
13567
|
+
addBuilderToScope(builder);
|
|
13568
|
+
return builder;
|
|
13247
13569
|
}
|
|
13248
13570
|
|
|
13249
13571
|
/**
|
|
@@ -13537,8 +13859,7 @@ function createAnimationState(visualElement) {
|
|
|
13537
13859
|
const valueHasChanged = Array.isArray(next) && Array.isArray(prev)
|
|
13538
13860
|
? !shallowCompare(next, prev) || variantDidChange
|
|
13539
13861
|
: next !== prev;
|
|
13540
|
-
if (valueHasChanged &&
|
|
13541
|
-
(next === undefined || next === null)) {
|
|
13862
|
+
if (valueHasChanged && (next === undefined || next === null)) {
|
|
13542
13863
|
removedKeys.add(key);
|
|
13543
13864
|
}
|
|
13544
13865
|
else if (valueHasChanged ||
|
|
@@ -13753,7 +14074,12 @@ function nodeGroup() {
|
|
|
13753
14074
|
*/
|
|
13754
14075
|
function animateLayout(scopeOrUpdateDom, updateDomOrOptions, options) {
|
|
13755
14076
|
const { scope, updateDom, defaultOptions } = parseAnimateLayoutArgs(scopeOrUpdateDom, updateDomOrOptions, options);
|
|
13756
|
-
|
|
14077
|
+
const builder = new LayoutAnimationBuilder(scope, updateDom, {
|
|
14078
|
+
...activeScope.current?.transition,
|
|
14079
|
+
...defaultOptions,
|
|
14080
|
+
});
|
|
14081
|
+
addBuilderToScope(builder);
|
|
14082
|
+
return builder;
|
|
13757
14083
|
}
|
|
13758
14084
|
|
|
13759
14085
|
/**
|
|
@@ -13798,7 +14124,9 @@ exports.ViewTransitionBuilder = ViewTransitionBuilder;
|
|
|
13798
14124
|
exports.VisualElement = VisualElement;
|
|
13799
14125
|
exports.VisualElementDragControls = VisualElementDragControls;
|
|
13800
14126
|
exports.acceleratedValues = acceleratedValues;
|
|
14127
|
+
exports.activeScope = activeScope;
|
|
13801
14128
|
exports.addAttrValue = addAttrValue;
|
|
14129
|
+
exports.addBuilderToScope = addBuilderToScope;
|
|
13802
14130
|
exports.addDomEvent = addDomEvent;
|
|
13803
14131
|
exports.addEffect = addEffect;
|
|
13804
14132
|
exports.addPointerEvent = addPointerEvent;
|
|
@@ -13806,6 +14134,7 @@ exports.addPointerInfo = addPointerInfo;
|
|
|
13806
14134
|
exports.addSVGValue = addSVGValue;
|
|
13807
14135
|
exports.addScaleCorrector = addScaleCorrector;
|
|
13808
14136
|
exports.addStyleValue = addStyleValue;
|
|
14137
|
+
exports.addToScope = addToScope;
|
|
13809
14138
|
exports.addValueToWillChange = addValueToWillChange;
|
|
13810
14139
|
exports.alpha = alpha;
|
|
13811
14140
|
exports.analyseComplexValue = analyseComplexValue;
|
|
@@ -13835,6 +14164,7 @@ exports.attrEffect = attrEffect;
|
|
|
13835
14164
|
exports.axisDeltaEquals = axisDeltaEquals;
|
|
13836
14165
|
exports.axisEquals = axisEquals;
|
|
13837
14166
|
exports.axisEqualsRounded = axisEqualsRounded;
|
|
14167
|
+
exports.bindToScope = bindToScope;
|
|
13838
14168
|
exports.boxEquals = boxEquals;
|
|
13839
14169
|
exports.boxEqualsRounded = boxEqualsRounded;
|
|
13840
14170
|
exports.buildHTMLStyles = buildHTMLStyles;
|
|
@@ -13996,6 +14326,7 @@ exports.pixelsToPercent = pixelsToPercent;
|
|
|
13996
14326
|
exports.positionalKeys = positionalKeys;
|
|
13997
14327
|
exports.prefersReducedMotion = prefersReducedMotion;
|
|
13998
14328
|
exports.press = press;
|
|
14329
|
+
exports.processFrame = processFrame;
|
|
13999
14330
|
exports.progressPercentage = progressPercentage;
|
|
14000
14331
|
exports.propEffect = propEffect;
|
|
14001
14332
|
exports.propagateDirtyNodes = propagateDirtyNodes;
|
|
@@ -14004,6 +14335,7 @@ exports.readSVGValue = readSVGValue;
|
|
|
14004
14335
|
exports.readStyleValue = readStyleValue;
|
|
14005
14336
|
exports.readTransformValue = readTransformValue;
|
|
14006
14337
|
exports.recordStats = recordStats;
|
|
14338
|
+
exports.releaseElement = releaseElement;
|
|
14007
14339
|
exports.removeAxisDelta = removeAxisDelta;
|
|
14008
14340
|
exports.removeAxisTransforms = removeAxisTransforms;
|
|
14009
14341
|
exports.removeBoxTransforms = removeBoxTransforms;
|
|
@@ -14025,6 +14357,7 @@ exports.sampleDelta = sampleDelta;
|
|
|
14025
14357
|
exports.scale = scale;
|
|
14026
14358
|
exports.scaleCorrectors = scaleCorrectors;
|
|
14027
14359
|
exports.scalePoint = scalePoint;
|
|
14360
|
+
exports.scopeMotion = scopeMotion;
|
|
14028
14361
|
exports.scrapeHTMLMotionValuesFromProps = scrapeMotionValuesFromProps$1;
|
|
14029
14362
|
exports.scrapeSVGMotionValuesFromProps = scrapeMotionValuesFromProps;
|
|
14030
14363
|
exports.setDragLock = setDragLock;
|
|
@@ -14051,6 +14384,7 @@ exports.svgSubjectEffect = svgSubjectEffect;
|
|
|
14051
14384
|
exports.sync = sync;
|
|
14052
14385
|
exports.testValueType = testValueType;
|
|
14053
14386
|
exports.time = time;
|
|
14387
|
+
exports.toMediaQuery = toMediaQuery;
|
|
14054
14388
|
exports.transform = transform;
|
|
14055
14389
|
exports.transformAxis = transformAxis;
|
|
14056
14390
|
exports.transformBox = transformBox;
|