framer-motion 12.20.5 → 12.22.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/client.js +1 -1
- package/dist/cjs/{create-BOq2yHIj.js → create-Dr1Bf9gl.js} +20 -15
- package/dist/cjs/dom.js +0 -24
- package/dist/cjs/index.js +1 -25
- package/dist/dom.d.ts +2 -10
- package/dist/dom.js +1 -1
- package/dist/es/animation/interfaces/visual-element-variant.mjs +14 -7
- package/dist/es/dom.mjs +0 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +2 -5
- package/dist/es/gestures/pan/PanSession.mjs +4 -3
- package/dist/es/index.mjs +0 -1
- package/dist/framer-motion.dev.js +44 -38
- package/dist/framer-motion.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/types/index.d.ts +13 -11
- package/package.json +3 -3
- package/dist/es/animation/utils/stagger.mjs +0 -26
|
@@ -4492,6 +4492,29 @@
|
|
|
4492
4492
|
return isSVGElement(element) && element.tagName === "svg";
|
|
4493
4493
|
}
|
|
4494
4494
|
|
|
4495
|
+
function getOriginIndex(from, total) {
|
|
4496
|
+
if (from === "first") {
|
|
4497
|
+
return 0;
|
|
4498
|
+
}
|
|
4499
|
+
else {
|
|
4500
|
+
const lastIndex = total - 1;
|
|
4501
|
+
return from === "last" ? lastIndex : lastIndex / 2;
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
|
|
4505
|
+
return (i, total) => {
|
|
4506
|
+
const fromIndex = typeof from === "number" ? from : getOriginIndex(from, total);
|
|
4507
|
+
const distance = Math.abs(fromIndex - i);
|
|
4508
|
+
let delay = duration * distance;
|
|
4509
|
+
if (ease) {
|
|
4510
|
+
const maxDelay = total * duration;
|
|
4511
|
+
const easingFunction = easingDefinitionToFunction(ease);
|
|
4512
|
+
delay = easingFunction(delay / maxDelay) * maxDelay;
|
|
4513
|
+
}
|
|
4514
|
+
return startDelay + delay;
|
|
4515
|
+
};
|
|
4516
|
+
}
|
|
4517
|
+
|
|
4495
4518
|
function transform(...args) {
|
|
4496
4519
|
const useImmediate = !Array.isArray(args[0]);
|
|
4497
4520
|
const argOffset = useImmediate ? 0 : -1;
|
|
@@ -9239,7 +9262,7 @@
|
|
|
9239
9262
|
const getChildAnimations = visualElement.variantChildren && visualElement.variantChildren.size
|
|
9240
9263
|
? (forwardDelay = 0) => {
|
|
9241
9264
|
const { delayChildren = 0, staggerChildren, staggerDirection, } = transition;
|
|
9242
|
-
return animateChildren(visualElement, variant,
|
|
9265
|
+
return animateChildren(visualElement, variant, forwardDelay, delayChildren, staggerChildren, staggerDirection, options);
|
|
9243
9266
|
}
|
|
9244
9267
|
: () => Promise.resolve();
|
|
9245
9268
|
/**
|
|
@@ -9257,19 +9280,26 @@
|
|
|
9257
9280
|
return Promise.all([getAnimation(), getChildAnimations(options.delay)]);
|
|
9258
9281
|
}
|
|
9259
9282
|
}
|
|
9260
|
-
function animateChildren(visualElement, variant, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
|
|
9283
|
+
function animateChildren(visualElement, variant, delay = 0, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
|
|
9261
9284
|
const animations = [];
|
|
9262
|
-
const
|
|
9263
|
-
const
|
|
9264
|
-
|
|
9265
|
-
|
|
9285
|
+
const numChildren = visualElement.variantChildren.size;
|
|
9286
|
+
const maxStaggerDuration = (numChildren - 1) * staggerChildren;
|
|
9287
|
+
const delayIsFunction = typeof delayChildren === "function";
|
|
9288
|
+
const generateStaggerDuration = delayIsFunction
|
|
9289
|
+
? (i) => delayChildren(i, numChildren)
|
|
9290
|
+
: // Support deprecated staggerChildren
|
|
9291
|
+
staggerDirection === 1
|
|
9292
|
+
? (i = 0) => i * staggerChildren
|
|
9293
|
+
: (i = 0) => maxStaggerDuration - i * staggerChildren;
|
|
9266
9294
|
Array.from(visualElement.variantChildren)
|
|
9267
9295
|
.sort(sortByTreeOrder)
|
|
9268
9296
|
.forEach((child, i) => {
|
|
9269
9297
|
child.notify("AnimationStart", variant);
|
|
9270
9298
|
animations.push(animateVariant(child, variant, {
|
|
9271
9299
|
...options,
|
|
9272
|
-
delay:
|
|
9300
|
+
delay: delay +
|
|
9301
|
+
(delayIsFunction ? 0 : delayChildren) +
|
|
9302
|
+
generateStaggerDuration(i),
|
|
9273
9303
|
}).then(() => child.notify("AnimationComplete", variant)));
|
|
9274
9304
|
});
|
|
9275
9305
|
return Promise.all(animations);
|
|
@@ -9792,7 +9822,7 @@
|
|
|
9792
9822
|
* @internal
|
|
9793
9823
|
*/
|
|
9794
9824
|
class PanSession {
|
|
9795
|
-
constructor(event, handlers, { transformPagePoint, contextWindow, dragSnapToOrigin = false, } = {}) {
|
|
9825
|
+
constructor(event, handlers, { transformPagePoint, contextWindow = window, dragSnapToOrigin = false, distanceThreshold = 3, } = {}) {
|
|
9796
9826
|
/**
|
|
9797
9827
|
* @internal
|
|
9798
9828
|
*/
|
|
@@ -9820,8 +9850,8 @@
|
|
|
9820
9850
|
const isPanStarted = this.startEvent !== null;
|
|
9821
9851
|
// Only start panning if the offset is larger than 3 pixels. If we make it
|
|
9822
9852
|
// any larger than this we'll want to reset the pointer history
|
|
9823
|
-
// on the first update to avoid visual snapping to the
|
|
9824
|
-
const isDistancePastThreshold = distance2D(info.offset, { x: 0, y: 0 }) >=
|
|
9853
|
+
// on the first update to avoid visual snapping to the cursor.
|
|
9854
|
+
const isDistancePastThreshold = distance2D(info.offset, { x: 0, y: 0 }) >= this.distanceThreshold;
|
|
9825
9855
|
if (!isPanStarted && !isDistancePastThreshold)
|
|
9826
9856
|
return;
|
|
9827
9857
|
const { point } = info;
|
|
@@ -9861,6 +9891,7 @@
|
|
|
9861
9891
|
this.dragSnapToOrigin = dragSnapToOrigin;
|
|
9862
9892
|
this.handlers = handlers;
|
|
9863
9893
|
this.transformPagePoint = transformPagePoint;
|
|
9894
|
+
this.distanceThreshold = distanceThreshold;
|
|
9864
9895
|
this.contextWindow = contextWindow || window;
|
|
9865
9896
|
const info = extractEventInfo(event);
|
|
9866
9897
|
const initialInfo = transformPoint(info, this.transformPagePoint);
|
|
@@ -10059,10 +10090,6 @@
|
|
|
10059
10090
|
}
|
|
10060
10091
|
|
|
10061
10092
|
const elementDragControls = new WeakMap();
|
|
10062
|
-
/**
|
|
10063
|
-
*
|
|
10064
|
-
*/
|
|
10065
|
-
// let latestPointerEvent: PointerEvent
|
|
10066
10093
|
class VisualElementDragControls {
|
|
10067
10094
|
constructor(visualElement) {
|
|
10068
10095
|
this.openDragLock = null;
|
|
@@ -10080,7 +10107,7 @@
|
|
|
10080
10107
|
this.elastic = createBox();
|
|
10081
10108
|
this.visualElement = visualElement;
|
|
10082
10109
|
}
|
|
10083
|
-
start(originEvent, { snapToCursor = false } = {}) {
|
|
10110
|
+
start(originEvent, { snapToCursor = false, distanceThreshold } = {}) {
|
|
10084
10111
|
/**
|
|
10085
10112
|
* Don't start dragging if this component is exiting
|
|
10086
10113
|
*/
|
|
@@ -10187,6 +10214,7 @@
|
|
|
10187
10214
|
}, {
|
|
10188
10215
|
transformPagePoint: this.visualElement.getTransformPagePoint(),
|
|
10189
10216
|
dragSnapToOrigin,
|
|
10217
|
+
distanceThreshold,
|
|
10190
10218
|
contextWindow: getContextWindow(this.visualElement),
|
|
10191
10219
|
});
|
|
10192
10220
|
}
|
|
@@ -12919,29 +12947,6 @@
|
|
|
12919
12947
|
return () => observer.disconnect();
|
|
12920
12948
|
}
|
|
12921
12949
|
|
|
12922
|
-
function getOriginIndex(from, total) {
|
|
12923
|
-
if (from === "first") {
|
|
12924
|
-
return 0;
|
|
12925
|
-
}
|
|
12926
|
-
else {
|
|
12927
|
-
const lastIndex = total - 1;
|
|
12928
|
-
return from === "last" ? lastIndex : lastIndex / 2;
|
|
12929
|
-
}
|
|
12930
|
-
}
|
|
12931
|
-
function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
|
|
12932
|
-
return (i, total) => {
|
|
12933
|
-
const fromIndex = typeof from === "number" ? from : getOriginIndex(from, total);
|
|
12934
|
-
const distance = Math.abs(fromIndex - i);
|
|
12935
|
-
let delay = duration * distance;
|
|
12936
|
-
if (ease) {
|
|
12937
|
-
const maxDelay = total * duration;
|
|
12938
|
-
const easingFunction = easingDefinitionToFunction(ease);
|
|
12939
|
-
delay = easingFunction(delay / maxDelay) * maxDelay;
|
|
12940
|
-
}
|
|
12941
|
-
return startDelay + delay;
|
|
12942
|
-
};
|
|
12943
|
-
}
|
|
12944
|
-
|
|
12945
12950
|
const createMinimalMotionComponent =
|
|
12946
12951
|
/*@__PURE__*/ createMotionComponentFactory();
|
|
12947
12952
|
|
|
@@ -14051,6 +14056,7 @@
|
|
|
14051
14056
|
exports.getDefaultValueType = getDefaultValueType;
|
|
14052
14057
|
exports.getEasingForSegment = getEasingForSegment;
|
|
14053
14058
|
exports.getMixer = getMixer;
|
|
14059
|
+
exports.getOriginIndex = getOriginIndex;
|
|
14054
14060
|
exports.getValueAsType = getValueAsType;
|
|
14055
14061
|
exports.getValueTransition = getValueTransition$1;
|
|
14056
14062
|
exports.getVariableValue = getVariableValue;
|