motion-dom 12.34.0-alpha.0 → 12.34.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 +76 -118
- 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/value/index.mjs.map +1 -1
- package/dist/index.d.ts +15 -41
- package/dist/motion-dom.dev.js +76 -118
- 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
|
}
|
|
@@ -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) &&
|
|
@@ -5384,26 +5310,6 @@ const createBox = () => ({
|
|
|
5384
5310
|
y: createAxis(),
|
|
5385
5311
|
});
|
|
5386
5312
|
|
|
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
5313
|
const visualElementStore = new WeakMap();
|
|
5408
5314
|
|
|
5409
5315
|
function isAnimationControls(v) {
|
|
@@ -5489,6 +5395,26 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
5489
5395
|
return next;
|
|
5490
5396
|
}
|
|
5491
5397
|
|
|
5398
|
+
// Does this device prefer reduced motion? Returns `null` server-side.
|
|
5399
|
+
const prefersReducedMotion = { current: null };
|
|
5400
|
+
const hasReducedMotionListener = { current: false };
|
|
5401
|
+
|
|
5402
|
+
const isBrowser = typeof window !== "undefined";
|
|
5403
|
+
function initPrefersReducedMotion() {
|
|
5404
|
+
hasReducedMotionListener.current = true;
|
|
5405
|
+
if (!isBrowser)
|
|
5406
|
+
return;
|
|
5407
|
+
if (window.matchMedia) {
|
|
5408
|
+
const motionMediaQuery = window.matchMedia("(prefers-reduced-motion)");
|
|
5409
|
+
const setReducedMotionPreferences = () => (prefersReducedMotion.current = motionMediaQuery.matches);
|
|
5410
|
+
motionMediaQuery.addEventListener("change", setReducedMotionPreferences);
|
|
5411
|
+
setReducedMotionPreferences();
|
|
5412
|
+
}
|
|
5413
|
+
else {
|
|
5414
|
+
prefersReducedMotion.current = false;
|
|
5415
|
+
}
|
|
5416
|
+
}
|
|
5417
|
+
|
|
5492
5418
|
const propEventHandlers = [
|
|
5493
5419
|
"AnimationStart",
|
|
5494
5420
|
"AnimationComplete",
|
|
@@ -5729,6 +5655,25 @@ class VisualElement {
|
|
|
5729
5655
|
if (this.valueSubscriptions.has(key)) {
|
|
5730
5656
|
this.valueSubscriptions.get(key)();
|
|
5731
5657
|
}
|
|
5658
|
+
if (value.accelerate &&
|
|
5659
|
+
acceleratedValues.has(key) &&
|
|
5660
|
+
this.current instanceof HTMLElement) {
|
|
5661
|
+
const { factory, keyframes, times, ease, duration } = value.accelerate;
|
|
5662
|
+
const animation = new NativeAnimation({
|
|
5663
|
+
element: this.current,
|
|
5664
|
+
name: key,
|
|
5665
|
+
keyframes,
|
|
5666
|
+
times,
|
|
5667
|
+
ease,
|
|
5668
|
+
duration: motionUtils.secondsToMilliseconds(duration),
|
|
5669
|
+
});
|
|
5670
|
+
const cleanup = factory(animation);
|
|
5671
|
+
this.valueSubscriptions.set(key, () => {
|
|
5672
|
+
cleanup();
|
|
5673
|
+
animation.cancel();
|
|
5674
|
+
});
|
|
5675
|
+
return;
|
|
5676
|
+
}
|
|
5732
5677
|
const valueIsTransform = transformProps.has(key);
|
|
5733
5678
|
if (valueIsTransform && this.onBindTransform) {
|
|
5734
5679
|
this.onBindTransform();
|
|
@@ -5742,7 +5687,8 @@ class VisualElement {
|
|
|
5742
5687
|
this.scheduleRender();
|
|
5743
5688
|
});
|
|
5744
5689
|
let removeSyncCheck;
|
|
5745
|
-
if (typeof window !== "undefined" &&
|
|
5690
|
+
if (typeof window !== "undefined" &&
|
|
5691
|
+
window.MotionCheckAppearSync) {
|
|
5746
5692
|
removeSyncCheck = window.MotionCheckAppearSync(this, key, value);
|
|
5747
5693
|
}
|
|
5748
5694
|
this.valueSubscriptions.set(key, () => {
|
|
@@ -7489,6 +7435,15 @@ class NodeStack {
|
|
|
7489
7435
|
}
|
|
7490
7436
|
add(node) {
|
|
7491
7437
|
motionUtils.addUniqueItem(this.members, node);
|
|
7438
|
+
for (let i = this.members.length - 1; i >= 0; i--) {
|
|
7439
|
+
const m = this.members[i];
|
|
7440
|
+
if (m === node || m === this.lead || m === this.prevLead)
|
|
7441
|
+
continue;
|
|
7442
|
+
const inst = m.instance;
|
|
7443
|
+
if (inst && inst.isConnected === false && m.isPresent !== false && !m.snapshot) {
|
|
7444
|
+
motionUtils.removeItem(this.members, m);
|
|
7445
|
+
}
|
|
7446
|
+
}
|
|
7492
7447
|
node.scheduleRender();
|
|
7493
7448
|
}
|
|
7494
7449
|
remove(node) {
|
|
@@ -7513,7 +7468,8 @@ class NodeStack {
|
|
|
7513
7468
|
let prevLead;
|
|
7514
7469
|
for (let i = indexOfNode; i >= 0; i--) {
|
|
7515
7470
|
const member = this.members[i];
|
|
7516
|
-
|
|
7471
|
+
const inst = member.instance;
|
|
7472
|
+
if (member.isPresent !== false && (!inst || inst.isConnected !== false)) {
|
|
7517
7473
|
prevLead = member;
|
|
7518
7474
|
break;
|
|
7519
7475
|
}
|
|
@@ -7548,17 +7504,21 @@ class NodeStack {
|
|
|
7548
7504
|
nextDep !== undefined &&
|
|
7549
7505
|
prevDep === nextDep;
|
|
7550
7506
|
if (!dependencyMatches) {
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7507
|
+
const prevInstance = prevLead.instance;
|
|
7508
|
+
const isStale = prevInstance && prevInstance.isConnected === false && !prevLead.snapshot;
|
|
7509
|
+
if (!isStale) {
|
|
7510
|
+
node.resumeFrom = prevLead;
|
|
7511
|
+
if (preserveFollowOpacity) {
|
|
7512
|
+
node.resumeFrom.preserveOpacity = true;
|
|
7513
|
+
}
|
|
7514
|
+
if (prevLead.snapshot) {
|
|
7515
|
+
node.snapshot = prevLead.snapshot;
|
|
7516
|
+
node.snapshot.latestValues =
|
|
7517
|
+
prevLead.animationValues || prevLead.latestValues;
|
|
7518
|
+
}
|
|
7519
|
+
if (node.root && node.root.isUpdating) {
|
|
7520
|
+
node.isLayoutDirty = true;
|
|
7521
|
+
}
|
|
7562
7522
|
}
|
|
7563
7523
|
}
|
|
7564
7524
|
const { crossfade } = node.options;
|
|
@@ -9740,7 +9700,6 @@ exports.pixelsToPercent = pixelsToPercent;
|
|
|
9740
9700
|
exports.positionalKeys = positionalKeys;
|
|
9741
9701
|
exports.prefersReducedMotion = prefersReducedMotion;
|
|
9742
9702
|
exports.press = press;
|
|
9743
|
-
exports.processFrame = processFrame;
|
|
9744
9703
|
exports.progressPercentage = progressPercentage;
|
|
9745
9704
|
exports.propEffect = propEffect;
|
|
9746
9705
|
exports.propagateDirtyNodes = propagateDirtyNodes;
|
|
@@ -9751,7 +9710,6 @@ exports.removeAxisDelta = removeAxisDelta;
|
|
|
9751
9710
|
exports.removeAxisTransforms = removeAxisTransforms;
|
|
9752
9711
|
exports.removeBoxTransforms = removeBoxTransforms;
|
|
9753
9712
|
exports.removePointDelta = removePointDelta;
|
|
9754
|
-
exports.renderFrame = renderFrame;
|
|
9755
9713
|
exports.renderHTML = renderHTML;
|
|
9756
9714
|
exports.renderSVG = renderSVG;
|
|
9757
9715
|
exports.resize = resize;
|