framer-motion 12.6.2 → 12.6.3
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/client.js +1 -1
- package/dist/cjs/{create-BLp_edji.js → create-B2InJs4e.js} +68 -115
- package/dist/cjs/dom-mini.js +14 -219
- package/dist/cjs/dom.js +56 -199
- package/dist/cjs/index.js +32 -156
- package/dist/cjs/m.js +8 -12
- package/dist/cjs/mini.js +10 -214
- package/dist/dom-mini.d.ts +3 -3
- package/dist/dom-mini.js +1 -1
- package/dist/dom.d.ts +17 -14
- package/dist/dom.js +1 -1
- package/dist/es/animation/animate/index.mjs +2 -2
- package/dist/es/animation/animators/AcceleratedAnimation.mjs +5 -3
- package/dist/es/animation/animators/MainThreadAnimation.mjs +6 -4
- package/dist/es/animation/animators/waapi/animate-elements.mjs +10 -9
- package/dist/es/animation/animators/waapi/animate-sequence.mjs +2 -2
- package/dist/es/animation/animators/waapi/animate-style.mjs +2 -2
- package/dist/es/animation/generators/spring/index.mjs +9 -1
- package/dist/es/animation/interfaces/motion-value.mjs +2 -2
- package/dist/es/animation/interfaces/visual-element-target.mjs +1 -2
- package/dist/es/animation/interfaces/visual-element-variant.mjs +1 -2
- package/dist/es/animation/optimized-appear/handoff.mjs +2 -4
- package/dist/es/animation/optimized-appear/start.mjs +4 -6
- package/dist/es/animation/sequence/create.mjs +2 -2
- package/dist/es/animation/sequence/utils/calc-time.mjs +1 -2
- package/dist/es/components/AnimatePresence/index.mjs +2 -2
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +5 -10
- package/dist/es/motion/features/animation/index.mjs +1 -2
- package/dist/es/motion/index.mjs +2 -3
- package/dist/es/motion/utils/use-visual-element.mjs +3 -5
- package/dist/es/projection/node/create-projection-node.mjs +17 -25
- package/dist/es/projection/styles/transform.mjs +1 -1
- package/dist/es/render/VisualElement.mjs +3 -4
- package/dist/es/render/dom/DOMKeyframesResolver.mjs +1 -2
- package/dist/es/render/dom/resize/handle-element.mjs +5 -6
- package/dist/es/render/dom/scroll/track.mjs +1 -2
- package/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
- package/dist/es/render/dom/utils/filter-props.mjs +1 -1
- package/dist/es/render/html/utils/scrape-motion-values.mjs +1 -2
- package/dist/es/render/utils/KeyframesResolver.mjs +2 -3
- package/dist/es/render/utils/animation-state.mjs +3 -5
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/render/utils/resolve-variants.mjs +1 -1
- package/dist/es/utils/mix/complex.mjs +1 -2
- package/dist/es/value/types/complex/index.mjs +2 -3
- package/dist/es/value/use-scroll.mjs +2 -2
- package/dist/framer-motion.dev.js +445 -414
- package/dist/framer-motion.js +1 -1
- package/dist/mini.d.ts +1 -1
- package/dist/mini.js +1 -1
- package/dist/size-rollup-animate.js +1 -1
- package/dist/size-rollup-dom-animation-assets.js +1 -1
- package/dist/size-rollup-dom-animation-m.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max-assets.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-rollup-scroll.js +1 -1
- package/dist/size-rollup-waapi-animate.js +1 -1
- package/dist/types/index.d.ts +28 -31
- package/package.json +4 -4
- package/dist/es/animation/animators/waapi/NativeAnimation.mjs +0 -112
- package/dist/es/animation/animators/waapi/index.mjs +0 -32
- package/dist/es/animation/animators/waapi/utils/style.mjs +0 -8
- package/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +0 -13
package/dist/cjs/dom-mini.js
CHANGED
|
@@ -87,7 +87,6 @@ function calculateRepeatDuration(duration, repeat, _repeatDelay) {
|
|
|
87
87
|
* calculate an absolute time for the next keyframes.
|
|
88
88
|
*/
|
|
89
89
|
function calcNextTime(current, next, prev, labels) {
|
|
90
|
-
var _a;
|
|
91
90
|
if (typeof next === "number") {
|
|
92
91
|
return next;
|
|
93
92
|
}
|
|
@@ -98,7 +97,7 @@ function calcNextTime(current, next, prev, labels) {
|
|
|
98
97
|
return prev;
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
101
|
-
return
|
|
100
|
+
return labels.get(next) ?? current;
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
|
|
@@ -211,7 +210,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
211
210
|
const numKeyframes = valueKeyframesAsList.length;
|
|
212
211
|
const createGenerator = motionDom.isGenerator(type)
|
|
213
212
|
? type
|
|
214
|
-
: generators
|
|
213
|
+
: generators?.[type];
|
|
215
214
|
if (numKeyframes <= 2 && createGenerator) {
|
|
216
215
|
/**
|
|
217
216
|
* As we're creating an easing function from a spring,
|
|
@@ -233,7 +232,7 @@ function createAnimationsFromSequence(sequence, { defaultTransition = {}, ...seq
|
|
|
233
232
|
ease = springEasing.ease;
|
|
234
233
|
duration = springEasing.duration;
|
|
235
234
|
}
|
|
236
|
-
duration
|
|
235
|
+
duration ?? (duration = defaultDuration);
|
|
237
236
|
const startTime = currentTime + calculatedDelay;
|
|
238
237
|
/**
|
|
239
238
|
* If there's only one time offset of 0, fill in a second with length 1
|
|
@@ -392,212 +391,6 @@ function getValueTransition(transition, key) {
|
|
|
392
391
|
const isNumber = (keyframe) => typeof keyframe === "number";
|
|
393
392
|
const isNumberKeyframesArray = (keyframes) => keyframes.every(isNumber);
|
|
394
393
|
|
|
395
|
-
function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeInOut", times, } = {}) {
|
|
396
|
-
const keyframeOptions = { [valueName]: keyframes };
|
|
397
|
-
if (times)
|
|
398
|
-
keyframeOptions.offset = times;
|
|
399
|
-
const easing = motionDom.mapEasingToNativeEasing(ease, duration);
|
|
400
|
-
/**
|
|
401
|
-
* If this is an easing array, apply to keyframes, not animation as a whole
|
|
402
|
-
*/
|
|
403
|
-
if (Array.isArray(easing))
|
|
404
|
-
keyframeOptions.easing = easing;
|
|
405
|
-
if (motionDom.statsBuffer.value) {
|
|
406
|
-
motionDom.activeAnimations.waapi++;
|
|
407
|
-
}
|
|
408
|
-
const animation = element.animate(keyframeOptions, {
|
|
409
|
-
delay,
|
|
410
|
-
duration,
|
|
411
|
-
easing: !Array.isArray(easing) ? easing : "linear",
|
|
412
|
-
fill: "both",
|
|
413
|
-
iterations: repeat + 1,
|
|
414
|
-
direction: repeatType === "reverse" ? "alternate" : "normal",
|
|
415
|
-
});
|
|
416
|
-
if (motionDom.statsBuffer.value) {
|
|
417
|
-
animation.finished.finally(() => {
|
|
418
|
-
motionDom.activeAnimations.waapi--;
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
return animation;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
const createUnitType = (unit) => ({
|
|
425
|
-
test: (v) => typeof v === "string" && v.endsWith(unit) && v.split(" ").length === 1,
|
|
426
|
-
parse: parseFloat,
|
|
427
|
-
transform: (v) => `${v}${unit}`,
|
|
428
|
-
});
|
|
429
|
-
const px = /*@__PURE__*/ createUnitType("px");
|
|
430
|
-
|
|
431
|
-
const browserNumberValueTypes = {
|
|
432
|
-
// Border props
|
|
433
|
-
borderWidth: px,
|
|
434
|
-
borderTopWidth: px,
|
|
435
|
-
borderRightWidth: px,
|
|
436
|
-
borderBottomWidth: px,
|
|
437
|
-
borderLeftWidth: px,
|
|
438
|
-
borderRadius: px,
|
|
439
|
-
radius: px,
|
|
440
|
-
borderTopLeftRadius: px,
|
|
441
|
-
borderTopRightRadius: px,
|
|
442
|
-
borderBottomRightRadius: px,
|
|
443
|
-
borderBottomLeftRadius: px,
|
|
444
|
-
// Positioning props
|
|
445
|
-
width: px,
|
|
446
|
-
maxWidth: px,
|
|
447
|
-
height: px,
|
|
448
|
-
maxHeight: px,
|
|
449
|
-
top: px,
|
|
450
|
-
right: px,
|
|
451
|
-
bottom: px,
|
|
452
|
-
left: px,
|
|
453
|
-
// Spacing props
|
|
454
|
-
padding: px,
|
|
455
|
-
paddingTop: px,
|
|
456
|
-
paddingRight: px,
|
|
457
|
-
paddingBottom: px,
|
|
458
|
-
paddingLeft: px,
|
|
459
|
-
margin: px,
|
|
460
|
-
marginTop: px,
|
|
461
|
-
marginRight: px,
|
|
462
|
-
marginBottom: px,
|
|
463
|
-
marginLeft: px,
|
|
464
|
-
// Misc
|
|
465
|
-
backgroundPositionX: px,
|
|
466
|
-
backgroundPositionY: px,
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
const isNotNull = (value) => value !== null;
|
|
470
|
-
function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyframe) {
|
|
471
|
-
const resolvedKeyframes = keyframes.filter(isNotNull);
|
|
472
|
-
const index = repeat && repeatType !== "loop" && repeat % 2 === 1
|
|
473
|
-
? 0
|
|
474
|
-
: resolvedKeyframes.length - 1;
|
|
475
|
-
return !index || finalKeyframe === undefined
|
|
476
|
-
? resolvedKeyframes[index]
|
|
477
|
-
: finalKeyframe;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
function setCSSVar(element, name, value) {
|
|
481
|
-
element.style.setProperty(name, value);
|
|
482
|
-
}
|
|
483
|
-
function setStyle(element, name, value) {
|
|
484
|
-
element.style[name] = value;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
const supportsPartialKeyframes = /*@__PURE__*/ motionUtils.memo(() => {
|
|
488
|
-
try {
|
|
489
|
-
document.createElement("div").animate({ opacity: [1] });
|
|
490
|
-
}
|
|
491
|
-
catch (e) {
|
|
492
|
-
return false;
|
|
493
|
-
}
|
|
494
|
-
return true;
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
const supportsWaapi = /*@__PURE__*/ motionUtils.memo(() => Object.hasOwnProperty.call(Element.prototype, "animate"));
|
|
498
|
-
|
|
499
|
-
const state = new WeakMap();
|
|
500
|
-
function hydrateKeyframes(valueName, keyframes, read) {
|
|
501
|
-
for (let i = 0; i < keyframes.length; i++) {
|
|
502
|
-
if (keyframes[i] === null) {
|
|
503
|
-
keyframes[i] = i === 0 ? read() : keyframes[i - 1];
|
|
504
|
-
}
|
|
505
|
-
if (typeof keyframes[i] === "number" &&
|
|
506
|
-
browserNumberValueTypes[valueName]) {
|
|
507
|
-
keyframes[i] = browserNumberValueTypes[valueName].transform(keyframes[i]);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
if (!supportsPartialKeyframes() && keyframes.length < 2) {
|
|
511
|
-
keyframes.unshift(read());
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
const defaultEasing = "easeOut";
|
|
515
|
-
function getElementAnimationState(element) {
|
|
516
|
-
const animationState = state.get(element) || new Map();
|
|
517
|
-
state.set(element, animationState);
|
|
518
|
-
return state.get(element);
|
|
519
|
-
}
|
|
520
|
-
class NativeAnimation extends motionDom.NativeAnimationControls {
|
|
521
|
-
constructor(element, valueName, valueKeyframes, options) {
|
|
522
|
-
const isCSSVar = valueName.startsWith("--");
|
|
523
|
-
motionUtils.invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "framer-motion"?`);
|
|
524
|
-
const existingAnimation = getElementAnimationState(element).get(valueName);
|
|
525
|
-
existingAnimation && existingAnimation.stop();
|
|
526
|
-
const readInitialKeyframe = () => {
|
|
527
|
-
return valueName.startsWith("--")
|
|
528
|
-
? element.style.getPropertyValue(valueName)
|
|
529
|
-
: window.getComputedStyle(element)[valueName];
|
|
530
|
-
};
|
|
531
|
-
if (!Array.isArray(valueKeyframes)) {
|
|
532
|
-
valueKeyframes = [valueKeyframes];
|
|
533
|
-
}
|
|
534
|
-
hydrateKeyframes(valueName, valueKeyframes, readInitialKeyframe);
|
|
535
|
-
// TODO: Replace this with toString()?
|
|
536
|
-
if (motionDom.isGenerator(options.type)) {
|
|
537
|
-
const generatorOptions = motionDom.createGeneratorEasing(options, 100, options.type);
|
|
538
|
-
options.ease = motionDom.supportsLinearEasing()
|
|
539
|
-
? generatorOptions.ease
|
|
540
|
-
: defaultEasing;
|
|
541
|
-
options.duration = motionUtils.secondsToMilliseconds(generatorOptions.duration);
|
|
542
|
-
options.type = "keyframes";
|
|
543
|
-
}
|
|
544
|
-
else {
|
|
545
|
-
options.ease = options.ease || defaultEasing;
|
|
546
|
-
}
|
|
547
|
-
const onFinish = () => {
|
|
548
|
-
this.setValue(element, valueName, getFinalKeyframe(valueKeyframes, options));
|
|
549
|
-
this.cancel();
|
|
550
|
-
this.resolveFinishedPromise();
|
|
551
|
-
};
|
|
552
|
-
const init = () => {
|
|
553
|
-
this.setValue = isCSSVar ? setCSSVar : setStyle;
|
|
554
|
-
this.options = options;
|
|
555
|
-
this.updateFinishedPromise();
|
|
556
|
-
this.removeAnimation = () => {
|
|
557
|
-
const elementState = state.get(element);
|
|
558
|
-
elementState && elementState.delete(valueName);
|
|
559
|
-
};
|
|
560
|
-
};
|
|
561
|
-
if (!supportsWaapi()) {
|
|
562
|
-
super();
|
|
563
|
-
init();
|
|
564
|
-
onFinish();
|
|
565
|
-
}
|
|
566
|
-
else {
|
|
567
|
-
super(startWaapiAnimation(element, valueName, valueKeyframes, options));
|
|
568
|
-
init();
|
|
569
|
-
if (options.autoplay === false) {
|
|
570
|
-
this.animation.pause();
|
|
571
|
-
}
|
|
572
|
-
this.animation.onfinish = onFinish;
|
|
573
|
-
getElementAnimationState(element).set(valueName, this);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
/**
|
|
577
|
-
* Allows the returned animation to be awaited or promise-chained. Currently
|
|
578
|
-
* resolves when the animation finishes at all but in a future update could/should
|
|
579
|
-
* reject if its cancels.
|
|
580
|
-
*/
|
|
581
|
-
then(resolve, reject) {
|
|
582
|
-
return this.currentFinishedPromise.then(resolve, reject);
|
|
583
|
-
}
|
|
584
|
-
updateFinishedPromise() {
|
|
585
|
-
this.currentFinishedPromise = new Promise((resolve) => {
|
|
586
|
-
this.resolveFinishedPromise = resolve;
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
play() {
|
|
590
|
-
if (this.state === "finished") {
|
|
591
|
-
this.updateFinishedPromise();
|
|
592
|
-
}
|
|
593
|
-
super.play();
|
|
594
|
-
}
|
|
595
|
-
cancel() {
|
|
596
|
-
this.removeAnimation();
|
|
597
|
-
super.cancel();
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
394
|
function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
602
395
|
const elements = motionDom.resolveElements(elementOrSelector, scope);
|
|
603
396
|
const numElements = elements.length;
|
|
@@ -617,13 +410,15 @@ function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
|
617
410
|
const valueOptions = {
|
|
618
411
|
...motionDom.getValueTransition(elementTransition, valueName),
|
|
619
412
|
};
|
|
620
|
-
valueOptions.duration = valueOptions.duration
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
413
|
+
valueOptions.duration && (valueOptions.duration = motionUtils.secondsToMilliseconds(valueOptions.duration));
|
|
414
|
+
valueOptions.delay && (valueOptions.delay = motionUtils.secondsToMilliseconds(valueOptions.delay));
|
|
415
|
+
animations.push(new motionDom.NativeAnimation({
|
|
416
|
+
element,
|
|
417
|
+
name: valueName,
|
|
418
|
+
keyframes: valueKeyframes,
|
|
419
|
+
transition: valueOptions,
|
|
420
|
+
allowFlatten: !elementTransition.type && !elementTransition.ease,
|
|
421
|
+
}));
|
|
627
422
|
}
|
|
628
423
|
}
|
|
629
424
|
return animations;
|
|
@@ -634,12 +429,12 @@ function animateSequence(definition, options) {
|
|
|
634
429
|
createAnimationsFromSequence(definition, options).forEach(({ keyframes, transition }, element) => {
|
|
635
430
|
animations.push(...animateElements(element, keyframes, transition));
|
|
636
431
|
});
|
|
637
|
-
return new motionDom.
|
|
432
|
+
return new motionDom.GroupAnimationWithThen(animations);
|
|
638
433
|
}
|
|
639
434
|
|
|
640
435
|
const createScopedWaapiAnimate = (scope) => {
|
|
641
436
|
function scopedAnimate(elementOrSelector, keyframes, options) {
|
|
642
|
-
return new motionDom.
|
|
437
|
+
return new motionDom.GroupAnimationWithThen(animateElements(elementOrSelector, keyframes, options, scope));
|
|
643
438
|
}
|
|
644
439
|
return scopedAnimate;
|
|
645
440
|
};
|