motion-dom 12.34.0-alpha.0 → 12.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +91 -121
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +4 -12
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +2 -3
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/frameloop/batcher.mjs +3 -25
- package/dist/es/frameloop/batcher.mjs.map +1 -1
- package/dist/es/frameloop/frame.mjs +2 -2
- package/dist/es/frameloop/frame.mjs.map +1 -1
- package/dist/es/frameloop/sync-time.mjs +1 -2
- package/dist/es/frameloop/sync-time.mjs.map +1 -1
- package/dist/es/index.mjs +1 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/projection/shared/stack.mjs +26 -12
- package/dist/es/projection/shared/stack.mjs.map +1 -1
- package/dist/es/render/VisualElement.mjs +30 -8
- package/dist/es/render/VisualElement.mjs.map +1 -1
- package/dist/es/utils/supports/scroll-timeline.mjs +2 -2
- package/dist/es/utils/supports/scroll-timeline.mjs.map +1 -1
- package/dist/es/value/index.mjs.map +1 -1
- package/dist/es/value/types/complex/mask.mjs +13 -0
- package/dist/es/value/types/complex/mask.mjs.map +1 -0
- package/dist/es/value/types/maps/defaults.mjs +3 -0
- package/dist/es/value/types/maps/defaults.mjs.map +1 -1
- package/dist/es/value/types/utils/animatable-none.mjs +3 -1
- package/dist/es/value/types/utils/animatable-none.mjs.map +1 -1
- package/dist/index.d.ts +15 -41
- package/dist/motion-dom.dev.js +91 -121
- 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 +2 -2
- package/dist/es/frameloop/render-frame.mjs +0 -48
- package/dist/es/frameloop/render-frame.mjs.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -146,7 +146,7 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
|
|
|
146
146
|
render.process(state);
|
|
147
147
|
postRender.process(state);
|
|
148
148
|
state.isProcessing = false;
|
|
149
|
-
if (runNextFrame && allowKeepAlive
|
|
149
|
+
if (runNextFrame && allowKeepAlive) {
|
|
150
150
|
useDefaultElapsed = false;
|
|
151
151
|
scheduleNextBatch(processBatch);
|
|
152
152
|
}
|
|
@@ -154,32 +154,10 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
|
|
|
154
154
|
const wake = () => {
|
|
155
155
|
runNextFrame = true;
|
|
156
156
|
useDefaultElapsed = true;
|
|
157
|
-
if (!state.isProcessing
|
|
158
|
-
(!motionUtils.MotionGlobalConfig.useManualTiming || !allowKeepAlive)) {
|
|
157
|
+
if (!state.isProcessing) {
|
|
159
158
|
scheduleNextBatch(processBatch);
|
|
160
159
|
}
|
|
161
160
|
};
|
|
162
|
-
/**
|
|
163
|
-
* Manually process all scheduled frame callbacks.
|
|
164
|
-
* Used for manual frame rendering in environments without requestAnimationFrame
|
|
165
|
-
* (e.g., WebXR, Remotion, server-side rendering of videos).
|
|
166
|
-
*/
|
|
167
|
-
const processFrame = (timestamp, delta) => {
|
|
168
|
-
runNextFrame = false;
|
|
169
|
-
state.delta = delta !== undefined ? delta : 1000 / 60;
|
|
170
|
-
state.timestamp = timestamp;
|
|
171
|
-
state.isProcessing = true;
|
|
172
|
-
// Unrolled render loop for better per-frame performance
|
|
173
|
-
setup.process(state);
|
|
174
|
-
read.process(state);
|
|
175
|
-
resolveKeyframes.process(state);
|
|
176
|
-
preUpdate.process(state);
|
|
177
|
-
update.process(state);
|
|
178
|
-
preRender.process(state);
|
|
179
|
-
render.process(state);
|
|
180
|
-
postRender.process(state);
|
|
181
|
-
state.isProcessing = false;
|
|
182
|
-
};
|
|
183
161
|
const schedule = stepsOrder.reduce((acc, key) => {
|
|
184
162
|
const step = steps[key];
|
|
185
163
|
acc[key] = (process, keepAlive = false, immediate = false) => {
|
|
@@ -194,10 +172,10 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
|
|
|
194
172
|
steps[stepsOrder[i]].cancel(process);
|
|
195
173
|
}
|
|
196
174
|
};
|
|
197
|
-
return { schedule, cancel, state, steps
|
|
175
|
+
return { schedule, cancel, state, steps };
|
|
198
176
|
}
|
|
199
177
|
|
|
200
|
-
const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps,
|
|
178
|
+
const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps, } = /* @__PURE__ */ createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : motionUtils.noop, true);
|
|
201
179
|
|
|
202
180
|
let now;
|
|
203
181
|
function clearTime() {
|
|
@@ -214,8 +192,7 @@ function clearTime() {
|
|
|
214
192
|
const time = {
|
|
215
193
|
now: () => {
|
|
216
194
|
if (now === undefined) {
|
|
217
|
-
time.set(frameData.isProcessing ||
|
|
218
|
-
motionUtils.MotionGlobalConfig.useManualTiming
|
|
195
|
+
time.set(frameData.isProcessing || motionUtils.MotionGlobalConfig.useManualTiming
|
|
219
196
|
? frameData.timestamp
|
|
220
197
|
: performance.now());
|
|
221
198
|
}
|
|
@@ -725,48 +702,6 @@ function mix(from, to, p) {
|
|
|
725
702
|
return mixer(from, to);
|
|
726
703
|
}
|
|
727
704
|
|
|
728
|
-
/**
|
|
729
|
-
* Manually render a single animation frame.
|
|
730
|
-
*
|
|
731
|
-
* Temporarily enables `useManualTiming` mode during frame processing
|
|
732
|
-
* to prevent requestAnimationFrame from auto-advancing animations.
|
|
733
|
-
*
|
|
734
|
-
* @example
|
|
735
|
-
* renderFrame({ timestamp: 1000 }) // Render at 1 second
|
|
736
|
-
*
|
|
737
|
-
* @example
|
|
738
|
-
* // Using frame number
|
|
739
|
-
* renderFrame({ frame: 30, fps: 30 }) // Render at frame 30 (1 second at 30fps)
|
|
740
|
-
*/
|
|
741
|
-
function renderFrame(options = {}) {
|
|
742
|
-
const { timestamp, frame, fps = 30, delta } = options;
|
|
743
|
-
let frameTimestamp;
|
|
744
|
-
let frameDelta;
|
|
745
|
-
if (timestamp !== undefined) {
|
|
746
|
-
frameTimestamp = timestamp;
|
|
747
|
-
frameDelta = delta !== undefined ? delta : 1000 / 60;
|
|
748
|
-
}
|
|
749
|
-
else if (frame !== undefined) {
|
|
750
|
-
// Convert frame number to milliseconds
|
|
751
|
-
frameTimestamp = (frame / fps) * 1000;
|
|
752
|
-
frameDelta = delta !== undefined ? delta : 1000 / fps;
|
|
753
|
-
}
|
|
754
|
-
else {
|
|
755
|
-
// Use current frameData timestamp + default delta if no timing info provided
|
|
756
|
-
frameDelta = delta !== undefined ? delta : 1000 / 60;
|
|
757
|
-
frameTimestamp = frameData.timestamp + frameDelta;
|
|
758
|
-
}
|
|
759
|
-
// Temporarily enable manual timing mode during frame processing
|
|
760
|
-
const previousManualTiming = motionUtils.MotionGlobalConfig.useManualTiming;
|
|
761
|
-
motionUtils.MotionGlobalConfig.useManualTiming = true;
|
|
762
|
-
// Set the synchronized time
|
|
763
|
-
time.set(frameTimestamp);
|
|
764
|
-
// Process the frame - this runs all registered callbacks
|
|
765
|
-
processFrame(frameTimestamp, frameDelta);
|
|
766
|
-
// Restore previous manual timing setting
|
|
767
|
-
motionUtils.MotionGlobalConfig.useManualTiming = previousManualTiming;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
705
|
const frameloopDriver = (update) => {
|
|
771
706
|
const passTimestamp = ({ timestamp }) => update(timestamp);
|
|
772
707
|
return {
|
|
@@ -1491,12 +1426,7 @@ class JSAnimation extends WithPromise {
|
|
|
1491
1426
|
this.currentTime = Math.max(timeWithoutDelay, 0);
|
|
1492
1427
|
// If this animation has finished, set the current time to the total duration.
|
|
1493
1428
|
if (this.state === "finished" && this.holdTime === null) {
|
|
1494
|
-
|
|
1495
|
-
this.state = "running";
|
|
1496
|
-
}
|
|
1497
|
-
else {
|
|
1498
|
-
this.currentTime = totalDuration;
|
|
1499
|
-
}
|
|
1429
|
+
this.currentTime = totalDuration;
|
|
1500
1430
|
}
|
|
1501
1431
|
let elapsed = this.currentTime;
|
|
1502
1432
|
let frameGenerator = generator;
|
|
@@ -1620,8 +1550,7 @@ class JSAnimation extends WithPromise {
|
|
|
1620
1550
|
play() {
|
|
1621
1551
|
if (this.isStopped)
|
|
1622
1552
|
return;
|
|
1623
|
-
const { startTime } = this.options;
|
|
1624
|
-
const driver = this.options.driver ?? frameloopDriver;
|
|
1553
|
+
const { driver = frameloopDriver, startTime } = this.options;
|
|
1625
1554
|
if (!this.driver) {
|
|
1626
1555
|
this.driver = driver((timestamp) => this.tick(timestamp));
|
|
1627
1556
|
}
|
|
@@ -1662,9 +1591,7 @@ class JSAnimation extends WithPromise {
|
|
|
1662
1591
|
}
|
|
1663
1592
|
finish() {
|
|
1664
1593
|
this.notifyFinished();
|
|
1665
|
-
|
|
1666
|
-
this.teardown();
|
|
1667
|
-
}
|
|
1594
|
+
this.teardown();
|
|
1668
1595
|
this.state = "finished";
|
|
1669
1596
|
this.options.onComplete?.();
|
|
1670
1597
|
}
|
|
@@ -2001,8 +1928,6 @@ function setStyle(element, name, value) {
|
|
|
2001
1928
|
: (element.style[name] = value);
|
|
2002
1929
|
}
|
|
2003
1930
|
|
|
2004
|
-
const supportsScrollTimeline = /* @__PURE__ */ motionUtils.memo(() => window.ScrollTimeline !== undefined);
|
|
2005
|
-
|
|
2006
1931
|
/**
|
|
2007
1932
|
* Add the ability for test suites to manually set support flags
|
|
2008
1933
|
* to better test more environments.
|
|
@@ -2014,6 +1939,8 @@ function memoSupports(callback, supportsFlag) {
|
|
|
2014
1939
|
return () => supportsFlags[supportsFlag] ?? memoized();
|
|
2015
1940
|
}
|
|
2016
1941
|
|
|
1942
|
+
const supportsScrollTimeline = /* @__PURE__ */ memoSupports(() => window.ScrollTimeline !== undefined, "scrollTimeline");
|
|
1943
|
+
|
|
2017
1944
|
const supportsLinearEasing = /*@__PURE__*/ memoSupports(() => {
|
|
2018
1945
|
try {
|
|
2019
1946
|
document
|
|
@@ -2444,8 +2371,7 @@ function supportsBrowserAnimation(options) {
|
|
|
2444
2371
|
return false;
|
|
2445
2372
|
}
|
|
2446
2373
|
const { onUpdate, transformTemplate } = motionValue.owner.getProps();
|
|
2447
|
-
return (
|
|
2448
|
-
supportsWaapi() &&
|
|
2374
|
+
return (supportsWaapi() &&
|
|
2449
2375
|
name &&
|
|
2450
2376
|
acceleratedValues$1.has(name) &&
|
|
2451
2377
|
(name !== "transform" || !transformTemplate) &&
|
|
@@ -3610,6 +3536,15 @@ const filter = {
|
|
|
3610
3536
|
},
|
|
3611
3537
|
};
|
|
3612
3538
|
|
|
3539
|
+
const mask = {
|
|
3540
|
+
...complex,
|
|
3541
|
+
getAnimatableNone: (v) => {
|
|
3542
|
+
const parsed = complex.parse(v);
|
|
3543
|
+
const transformer = complex.createTransformer(v);
|
|
3544
|
+
return transformer(parsed.map((v) => typeof v === "number" ? 0 : typeof v === "object" ? { ...v, alpha: 1 } : v));
|
|
3545
|
+
},
|
|
3546
|
+
};
|
|
3547
|
+
|
|
3613
3548
|
const int = {
|
|
3614
3549
|
...number,
|
|
3615
3550
|
transform: Math.round,
|
|
@@ -3725,15 +3660,18 @@ const defaultValueTypes = {
|
|
|
3725
3660
|
borderLeftColor: color,
|
|
3726
3661
|
filter,
|
|
3727
3662
|
WebkitFilter: filter,
|
|
3663
|
+
mask,
|
|
3664
|
+
WebkitMask: mask,
|
|
3728
3665
|
};
|
|
3729
3666
|
/**
|
|
3730
3667
|
* Gets the default ValueType for the provided value key
|
|
3731
3668
|
*/
|
|
3732
3669
|
const getDefaultValueType = (key) => defaultValueTypes[key];
|
|
3733
3670
|
|
|
3671
|
+
const customTypes = /*@__PURE__*/ new Set([filter, mask]);
|
|
3734
3672
|
function getAnimatableNone(key, value) {
|
|
3735
3673
|
let defaultValueType = getDefaultValueType(key);
|
|
3736
|
-
if (defaultValueType
|
|
3674
|
+
if (!customTypes.has(defaultValueType))
|
|
3737
3675
|
defaultValueType = complex;
|
|
3738
3676
|
// If value is not recognised as animatable, ie "none", create an animatable version origin based on the target
|
|
3739
3677
|
return defaultValueType.getAnimatableNone
|
|
@@ -5384,26 +5322,6 @@ const createBox = () => ({
|
|
|
5384
5322
|
y: createAxis(),
|
|
5385
5323
|
});
|
|
5386
5324
|
|
|
5387
|
-
// Does this device prefer reduced motion? Returns `null` server-side.
|
|
5388
|
-
const prefersReducedMotion = { current: null };
|
|
5389
|
-
const hasReducedMotionListener = { current: false };
|
|
5390
|
-
|
|
5391
|
-
const isBrowser = typeof window !== "undefined";
|
|
5392
|
-
function initPrefersReducedMotion() {
|
|
5393
|
-
hasReducedMotionListener.current = true;
|
|
5394
|
-
if (!isBrowser)
|
|
5395
|
-
return;
|
|
5396
|
-
if (window.matchMedia) {
|
|
5397
|
-
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
|
5398
|
-
const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
|
|
5399
|
-
motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
|
|
5400
|
-
setReducedMotionPreferences();
|
|
5401
|
-
}
|
|
5402
|
-
else {
|
|
5403
|
-
prefersReducedMotion.current = false;
|
|
5404
|
-
}
|
|
5405
|
-
}
|
|
5406
|
-
|
|
5407
5325
|
const visualElementStore = new WeakMap();
|
|
5408
5326
|
|
|
5409
5327
|
function isAnimationControls(v) {
|
|
@@ -5489,6 +5407,26 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
5489
5407
|
return next;
|
|
5490
5408
|
}
|
|
5491
5409
|
|
|
5410
|
+
// Does this device prefer reduced motion? Returns `null` server-side.
|
|
5411
|
+
const prefersReducedMotion = { current: null };
|
|
5412
|
+
const hasReducedMotionListener = { current: false };
|
|
5413
|
+
|
|
5414
|
+
const isBrowser = typeof window !== "undefined";
|
|
5415
|
+
function initPrefersReducedMotion() {
|
|
5416
|
+
hasReducedMotionListener.current = true;
|
|
5417
|
+
if (!isBrowser)
|
|
5418
|
+
return;
|
|
5419
|
+
if (window.matchMedia) {
|
|
5420
|
+
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
|
5421
|
+
const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
|
|
5422
|
+
motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
|
|
5423
|
+
setReducedMotionPreferences();
|
|
5424
|
+
}
|
|
5425
|
+
else {
|
|
5426
|
+
prefersReducedMotion.current = false;
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5429
|
+
|
|
5492
5430
|
const propEventHandlers = [
|
|
5493
5431
|
"AnimationStart",
|
|
5494
5432
|
"AnimationComplete",
|
|
@@ -5729,6 +5667,25 @@ class VisualElement {
|
|
|
5729
5667
|
if (this.valueSubscriptions.has(key)) {
|
|
5730
5668
|
this.valueSubscriptions.get(key)();
|
|
5731
5669
|
}
|
|
5670
|
+
if (value.accelerate &&
|
|
5671
|
+
acceleratedValues.has(key) &&
|
|
5672
|
+
this.current instanceof HTMLElement) {
|
|
5673
|
+
const { factory, keyframes, times, ease, duration } = value.accelerate;
|
|
5674
|
+
const animation = new NativeAnimation({
|
|
5675
|
+
element: this.current,
|
|
5676
|
+
name: key,
|
|
5677
|
+
keyframes,
|
|
5678
|
+
times,
|
|
5679
|
+
ease,
|
|
5680
|
+
duration: motionUtils.secondsToMilliseconds(duration),
|
|
5681
|
+
});
|
|
5682
|
+
const cleanup = factory(animation);
|
|
5683
|
+
this.valueSubscriptions.set(key, () => {
|
|
5684
|
+
cleanup();
|
|
5685
|
+
animation.cancel();
|
|
5686
|
+
});
|
|
5687
|
+
return;
|
|
5688
|
+
}
|
|
5732
5689
|
const valueIsTransform = transformProps.has(key);
|
|
5733
5690
|
if (valueIsTransform && this.onBindTransform) {
|
|
5734
5691
|
this.onBindTransform();
|
|
@@ -5742,7 +5699,8 @@ class VisualElement {
|
|
|
5742
5699
|
this.scheduleRender();
|
|
5743
5700
|
});
|
|
5744
5701
|
let removeSyncCheck;
|
|
5745
|
-
if (typeof window !== "undefined" &&
|
|
5702
|
+
if (typeof window !== "undefined" &&
|
|
5703
|
+
window.MotionCheckAppearSync) {
|
|
5746
5704
|
removeSyncCheck = window.MotionCheckAppearSync(this, key, value);
|
|
5747
5705
|
}
|
|
5748
5706
|
this.valueSubscriptions.set(key, () => {
|
|
@@ -7489,6 +7447,15 @@ class NodeStack {
|
|
|
7489
7447
|
}
|
|
7490
7448
|
add(node) {
|
|
7491
7449
|
motionUtils.addUniqueItem(this.members, node);
|
|
7450
|
+
for (let i = this.members.length - 1; i >= 0; i--) {
|
|
7451
|
+
const m = this.members[i];
|
|
7452
|
+
if (m === node || m === this.lead || m === this.prevLead)
|
|
7453
|
+
continue;
|
|
7454
|
+
const inst = m.instance;
|
|
7455
|
+
if (inst && inst.isConnected === false && m.isPresent !== false && !m.snapshot) {
|
|
7456
|
+
motionUtils.removeItem(this.members, m);
|
|
7457
|
+
}
|
|
7458
|
+
}
|
|
7492
7459
|
node.scheduleRender();
|
|
7493
7460
|
}
|
|
7494
7461
|
remove(node) {
|
|
@@ -7513,7 +7480,8 @@ class NodeStack {
|
|
|
7513
7480
|
let prevLead;
|
|
7514
7481
|
for (let i = indexOfNode; i >= 0; i--) {
|
|
7515
7482
|
const member = this.members[i];
|
|
7516
|
-
|
|
7483
|
+
const inst = member.instance;
|
|
7484
|
+
if (member.isPresent !== false && (!inst || inst.isConnected !== false)) {
|
|
7517
7485
|
prevLead = member;
|
|
7518
7486
|
break;
|
|
7519
7487
|
}
|
|
@@ -7548,17 +7516,21 @@ class NodeStack {
|
|
|
7548
7516
|
nextDep !== undefined &&
|
|
7549
7517
|
prevDep === nextDep;
|
|
7550
7518
|
if (!dependencyMatches) {
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7519
|
+
const prevInstance = prevLead.instance;
|
|
7520
|
+
const isStale = prevInstance && prevInstance.isConnected === false && !prevLead.snapshot;
|
|
7521
|
+
if (!isStale) {
|
|
7522
|
+
node.resumeFrom = prevLead;
|
|
7523
|
+
if (preserveFollowOpacity) {
|
|
7524
|
+
node.resumeFrom.preserveOpacity = true;
|
|
7525
|
+
}
|
|
7526
|
+
if (prevLead.snapshot) {
|
|
7527
|
+
node.snapshot = prevLead.snapshot;
|
|
7528
|
+
node.snapshot.latestValues =
|
|
7529
|
+
prevLead.animationValues || prevLead.latestValues;
|
|
7530
|
+
}
|
|
7531
|
+
if (node.root && node.root.isUpdating) {
|
|
7532
|
+
node.isLayoutDirty = true;
|
|
7533
|
+
}
|
|
7562
7534
|
}
|
|
7563
7535
|
}
|
|
7564
7536
|
const { crossfade } = node.options;
|
|
@@ -9740,7 +9712,6 @@ exports.pixelsToPercent = pixelsToPercent;
|
|
|
9740
9712
|
exports.positionalKeys = positionalKeys;
|
|
9741
9713
|
exports.prefersReducedMotion = prefersReducedMotion;
|
|
9742
9714
|
exports.press = press;
|
|
9743
|
-
exports.processFrame = processFrame;
|
|
9744
9715
|
exports.progressPercentage = progressPercentage;
|
|
9745
9716
|
exports.propEffect = propEffect;
|
|
9746
9717
|
exports.propagateDirtyNodes = propagateDirtyNodes;
|
|
@@ -9751,7 +9722,6 @@ exports.removeAxisDelta = removeAxisDelta;
|
|
|
9751
9722
|
exports.removeAxisTransforms = removeAxisTransforms;
|
|
9752
9723
|
exports.removeBoxTransforms = removeBoxTransforms;
|
|
9753
9724
|
exports.removePointDelta = removePointDelta;
|
|
9754
|
-
exports.renderFrame = renderFrame;
|
|
9755
9725
|
exports.renderHTML = renderHTML;
|
|
9756
9726
|
exports.renderSVG = renderSVG;
|
|
9757
9727
|
exports.resize = resize;
|