motion-dom 14.2.0 → 14.3.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 +257 -106
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/animate/effects.mjs +9 -1
- package/dist/es/animation/animate/effects.mjs.map +1 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs +3 -1
- package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
- package/dist/es/animation/utils/arc.mjs +4 -4
- package/dist/es/animation/utils/arc.mjs.map +1 -1
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +56 -8
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -1
- package/dist/es/effects/svg/index.mjs +1 -1
- package/dist/es/effects/svg/index.mjs.map +1 -1
- package/dist/es/projection/animation/mix-values.mjs +16 -3
- package/dist/es/projection/animation/mix-values.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +91 -73
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/projection/styles/transform.mjs +3 -1
- package/dist/es/projection/styles/transform.mjs.map +1 -1
- package/dist/es/projection/utils/has-transform.mjs +1 -0
- package/dist/es/projection/utils/has-transform.mjs.map +1 -1
- package/dist/es/render/dom/parse-transform.mjs +4 -2
- package/dist/es/render/dom/parse-transform.mjs.map +1 -1
- package/dist/es/render/svg/utils/scrape-motion-values.mjs +7 -2
- package/dist/es/render/svg/utils/scrape-motion-values.mjs.map +1 -1
- package/dist/es/render/utils/keys-transform.mjs +1 -0
- package/dist/es/render/utils/keys-transform.mjs.map +1 -1
- package/dist/es/utils/stagger.mjs +39 -6
- package/dist/es/utils/stagger.mjs.map +1 -1
- package/dist/es/value/types/complex/index.mjs +3 -2
- package/dist/es/value/types/complex/index.mjs.map +1 -1
- package/dist/es/value/utils/follow.mjs +19 -2
- package/dist/es/value/utils/follow.mjs.map +1 -1
- package/dist/index.d.ts +43 -6
- package/dist/motion-dom.dev.js +257 -106
- package/dist/motion-dom.js +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
|
@@ -290,82 +290,92 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
290
290
|
if (layoutId) {
|
|
291
291
|
this.root.registerSharedNode(layoutId, this);
|
|
292
292
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
293
|
+
this.addLayoutListener();
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Only register the layout animation handler if this node requires
|
|
297
|
+
* layout animation. This is called on mount, and again whenever options
|
|
298
|
+
* change, as `layout` or `layoutId` may be enabled after mount.
|
|
299
|
+
*/
|
|
300
|
+
addLayoutListener() {
|
|
301
|
+
const { layoutId, layout, visualElement, animate } = this.options;
|
|
302
|
+
if (!this.instance ||
|
|
303
|
+
this.hasLayoutListener ||
|
|
304
|
+
animate === false ||
|
|
305
|
+
!visualElement ||
|
|
306
|
+
!(layoutId || layout))
|
|
307
|
+
return;
|
|
308
|
+
this.hasLayoutListener = true;
|
|
309
|
+
this.addEventListener("didUpdate", ({ delta, hasLayoutChanged, hasRelativeLayoutChanged, layout: newLayout, }) => {
|
|
310
|
+
if (this.isAnimationBlocked) {
|
|
311
|
+
this.target = undefined;
|
|
312
|
+
this.relativeTarget = undefined;
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
// TODO: Check here if an animation exists
|
|
316
|
+
const layoutTransition = this.options.transition ||
|
|
317
|
+
visualElement.getDefaultTransition() ||
|
|
318
|
+
defaultLayoutTransition;
|
|
319
|
+
const { onLayoutAnimationStart, onLayoutAnimationComplete, } = visualElement.getProps();
|
|
320
|
+
/**
|
|
321
|
+
* The target layout of the element might stay the same,
|
|
322
|
+
* but its position relative to its parent has changed.
|
|
323
|
+
*/
|
|
324
|
+
const hasTargetChanged = !this.targetLayout ||
|
|
325
|
+
!boxEqualsRounded(this.targetLayout, newLayout);
|
|
326
|
+
/*
|
|
327
|
+
* Note: Disabled to fix relative animations always triggering new
|
|
328
|
+
* layout animations. If this causes further issues, we can try
|
|
329
|
+
* a different approach to detecting relative target changes.
|
|
330
|
+
*/
|
|
331
|
+
// || hasRelativeLayoutChanged
|
|
332
|
+
/**
|
|
333
|
+
* If the layout hasn't seemed to have changed, it might be that the
|
|
334
|
+
* element is visually in the same place in the document but its position
|
|
335
|
+
* relative to its parent has indeed changed. So here we check for that.
|
|
336
|
+
*/
|
|
337
|
+
const hasOnlyRelativeTargetChanged = !hasLayoutChanged && hasRelativeLayoutChanged;
|
|
338
|
+
if (this.options.layoutRoot ||
|
|
339
|
+
this.resumeFrom ||
|
|
340
|
+
hasOnlyRelativeTargetChanged ||
|
|
341
|
+
(hasLayoutChanged &&
|
|
342
|
+
(hasTargetChanged || !this.currentAnimation))) {
|
|
343
|
+
if (this.resumeFrom) {
|
|
344
|
+
this.resumingFrom = this.resumeFrom;
|
|
345
|
+
this.resumingFrom.resumingFrom = undefined;
|
|
346
|
+
}
|
|
347
|
+
const animationOptions = {
|
|
348
|
+
...getValueTransition(layoutTransition, "layout"),
|
|
349
|
+
onPlay: onLayoutAnimationStart,
|
|
350
|
+
onComplete: onLayoutAnimationComplete,
|
|
351
|
+
};
|
|
352
|
+
if (visualElement.shouldReduceMotion ||
|
|
353
|
+
this.options.layoutRoot) {
|
|
354
|
+
animationOptions.delay = 0;
|
|
355
|
+
animationOptions.type = false;
|
|
302
356
|
}
|
|
303
|
-
|
|
304
|
-
const layoutTransition = this.options.transition ||
|
|
305
|
-
visualElement.getDefaultTransition() ||
|
|
306
|
-
defaultLayoutTransition;
|
|
307
|
-
const { onLayoutAnimationStart, onLayoutAnimationComplete, } = visualElement.getProps();
|
|
357
|
+
this.startAnimation(animationOptions);
|
|
308
358
|
/**
|
|
309
|
-
*
|
|
310
|
-
*
|
|
359
|
+
* Set animation origin after starting animation to avoid layout jump
|
|
360
|
+
* caused by stopping previous layout animation
|
|
311
361
|
*/
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
* Note: Disabled to fix relative animations always triggering new
|
|
316
|
-
* layout animations. If this causes further issues, we can try
|
|
317
|
-
* a different approach to detecting relative target changes.
|
|
318
|
-
*/
|
|
319
|
-
// || hasRelativeLayoutChanged
|
|
362
|
+
this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged, animationOptions.path);
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
320
365
|
/**
|
|
321
|
-
* If the layout hasn't
|
|
322
|
-
*
|
|
323
|
-
*
|
|
366
|
+
* If the layout hasn't changed and we have an animation that hasn't started yet,
|
|
367
|
+
* finish it immediately. Otherwise it will be animating from a location
|
|
368
|
+
* that was probably never committed to screen and look like a jumpy box.
|
|
324
369
|
*/
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
this.resumeFrom ||
|
|
328
|
-
hasOnlyRelativeTargetChanged ||
|
|
329
|
-
(hasLayoutChanged &&
|
|
330
|
-
(hasTargetChanged || !this.currentAnimation))) {
|
|
331
|
-
if (this.resumeFrom) {
|
|
332
|
-
this.resumingFrom = this.resumeFrom;
|
|
333
|
-
this.resumingFrom.resumingFrom = undefined;
|
|
334
|
-
}
|
|
335
|
-
const animationOptions = {
|
|
336
|
-
...getValueTransition(layoutTransition, "layout"),
|
|
337
|
-
onPlay: onLayoutAnimationStart,
|
|
338
|
-
onComplete: onLayoutAnimationComplete,
|
|
339
|
-
};
|
|
340
|
-
if (visualElement.shouldReduceMotion ||
|
|
341
|
-
this.options.layoutRoot) {
|
|
342
|
-
animationOptions.delay = 0;
|
|
343
|
-
animationOptions.type = false;
|
|
344
|
-
}
|
|
345
|
-
this.startAnimation(animationOptions);
|
|
346
|
-
/**
|
|
347
|
-
* Set animation origin after starting animation to avoid layout jump
|
|
348
|
-
* caused by stopping previous layout animation
|
|
349
|
-
*/
|
|
350
|
-
this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged, animationOptions
|
|
351
|
-
.path);
|
|
370
|
+
if (!hasLayoutChanged) {
|
|
371
|
+
finishAnimation(this);
|
|
352
372
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
* If the layout hasn't changed and we have an animation that hasn't started yet,
|
|
356
|
-
* finish it immediately. Otherwise it will be animating from a location
|
|
357
|
-
* that was probably never committed to screen and look like a jumpy box.
|
|
358
|
-
*/
|
|
359
|
-
if (!hasLayoutChanged) {
|
|
360
|
-
finishAnimation(this);
|
|
361
|
-
}
|
|
362
|
-
if (this.isLead() && this.options.onExitComplete) {
|
|
363
|
-
this.options.onExitComplete();
|
|
364
|
-
}
|
|
373
|
+
if (this.isLead() && this.options.onExitComplete) {
|
|
374
|
+
this.options.onExitComplete();
|
|
365
375
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
}
|
|
376
|
+
}
|
|
377
|
+
this.targetLayout = newLayout;
|
|
378
|
+
});
|
|
369
379
|
}
|
|
370
380
|
unmount() {
|
|
371
381
|
this.options.layoutId && this.willUpdate();
|
|
@@ -375,6 +385,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
375
385
|
this.parent && this.parent.children.delete(this);
|
|
376
386
|
this.instance = undefined;
|
|
377
387
|
this.eventHandlers.clear();
|
|
388
|
+
this.hasLayoutListener = false;
|
|
378
389
|
cancelFrame(this.updateProjection);
|
|
379
390
|
}
|
|
380
391
|
// only on the root
|
|
@@ -545,7 +556,16 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
545
556
|
}
|
|
546
557
|
clearAllSnapshots() {
|
|
547
558
|
this.nodes.forEach(clearSnapshot);
|
|
548
|
-
|
|
559
|
+
/**
|
|
560
|
+
* A stack's last member can unmount while a replacement with the
|
|
561
|
+
* same layoutId mounts in the same commit, so the stack (and its
|
|
562
|
+
* lead) must outlive the unmount for the replacement to resume
|
|
563
|
+
* from it. By now that handoff has happened, so stacks that are
|
|
564
|
+
* still empty only retain unmounted nodes and can be released.
|
|
565
|
+
*/
|
|
566
|
+
this.sharedNodes.forEach((stack, layoutId) => stack.members.length
|
|
567
|
+
? stack.removeLeadSnapshot()
|
|
568
|
+
: this.sharedNodes.delete(layoutId));
|
|
549
569
|
}
|
|
550
570
|
scheduleUpdateProjection() {
|
|
551
571
|
if (!this.projectionUpdateScheduled) {
|
|
@@ -769,6 +789,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
769
789
|
...options,
|
|
770
790
|
crossfade: options.crossfade !== undefined ? options.crossfade : true,
|
|
771
791
|
};
|
|
792
|
+
this.addLayoutListener();
|
|
772
793
|
}
|
|
773
794
|
clearMeasurements() {
|
|
774
795
|
this.scroll = undefined;
|
|
@@ -1698,9 +1719,6 @@ function calcProjection(node) {
|
|
|
1698
1719
|
function resetSkewAndRotation(node) {
|
|
1699
1720
|
node.resetSkewAndRotation();
|
|
1700
1721
|
}
|
|
1701
|
-
function removeLeadSnapshots(stack) {
|
|
1702
|
-
stack.removeLeadSnapshot();
|
|
1703
|
-
}
|
|
1704
1722
|
function mixAxisDeltaLinear(output, delta, p) {
|
|
1705
1723
|
output.translate = mixNumber(delta.translate, 0, p);
|
|
1706
1724
|
output.scale = mixNumber(delta.scale, 1, p);
|