framer-motion 12.7.5 → 12.8.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-RWnxg4Sz.js → create-Bv1Fn_mR.js} +10 -17
- package/dist/cjs/dom.js +5 -25
- package/dist/cjs/index.js +2 -21
- package/dist/cjs/m.js +1 -8
- package/dist/dom.d.ts +1 -94
- package/dist/dom.js +1 -1
- package/dist/es/dom.mjs +0 -1
- package/dist/es/index.mjs +0 -1
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/render/utils/setters.mjs +5 -1
- package/dist/es/value/use-transform.mjs +1 -1
- package/dist/es/value/utils/resolve-motion-value.mjs +1 -5
- package/dist/framer-motion.dev.js +113 -42
- package/dist/framer-motion.js +1 -1
- package/dist/m.d.ts +7 -28
- package/dist/size-rollup-animate.js +1 -1
- package/dist/size-rollup-dom-animation-assets.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/types/client.d.ts +2 -2
- package/dist/types/index.d.ts +9 -102
- package/dist/{types.d-B1Voffvi.d.ts → types.d-DUA-weyD.d.ts} +9 -30
- package/package.json +3 -3
- package/dist/es/utils/resolve-value.mjs +0 -11
- package/dist/es/utils/transform.mjs +0 -21
package/dist/cjs/client.js
CHANGED
|
@@ -364,28 +364,13 @@ function delay(callback, timeout) {
|
|
|
364
364
|
return () => motionDom.cancelFrame(checkElapsed);
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
const isKeyframesTarget = (v) => {
|
|
368
|
-
return Array.isArray(v);
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
const isCustomValue = (v) => {
|
|
372
|
-
return Boolean(v && typeof v === "object" && v.mix && v.toValue);
|
|
373
|
-
};
|
|
374
|
-
const resolveFinalValueInKeyframes = (v) => {
|
|
375
|
-
// TODO maybe throw if v.length - 1 is placeholder token?
|
|
376
|
-
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
|
377
|
-
};
|
|
378
|
-
|
|
379
367
|
/**
|
|
380
368
|
* If the provided value is a MotionValue, this returns the actual value, otherwise just the value itself
|
|
381
369
|
*
|
|
382
370
|
* TODO: Remove and move to library
|
|
383
371
|
*/
|
|
384
372
|
function resolveMotionValue(value) {
|
|
385
|
-
|
|
386
|
-
return isCustomValue(unwrappedValue)
|
|
387
|
-
? unwrappedValue.toValue()
|
|
388
|
-
: unwrappedValue;
|
|
373
|
+
return isMotionValue(value) ? value.get() : value;
|
|
389
374
|
}
|
|
390
375
|
|
|
391
376
|
const borders = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"];
|
|
@@ -2735,7 +2720,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
2735
2720
|
* and warn against mismatches.
|
|
2736
2721
|
*/
|
|
2737
2722
|
if (process.env.NODE_ENV === "development") {
|
|
2738
|
-
motionUtils.warnOnce(nextValue.version === "12.
|
|
2723
|
+
motionUtils.warnOnce(nextValue.version === "12.8.0", `Attempting to mix Motion versions ${nextValue.version} with 12.8.0 may not work as expected.`);
|
|
2739
2724
|
}
|
|
2740
2725
|
}
|
|
2741
2726
|
else if (isMotionValue(prevValue)) {
|
|
@@ -3609,6 +3594,10 @@ function resolveVariant(visualElement, definition, custom) {
|
|
|
3609
3594
|
return resolveVariantFromProps(props, definition, custom !== undefined ? custom : props.custom, visualElement);
|
|
3610
3595
|
}
|
|
3611
3596
|
|
|
3597
|
+
const isKeyframesTarget = (v) => {
|
|
3598
|
+
return Array.isArray(v);
|
|
3599
|
+
};
|
|
3600
|
+
|
|
3612
3601
|
/**
|
|
3613
3602
|
* Set VisualElement's MotionValue, creating a new MotionValue for it if
|
|
3614
3603
|
* it doesn't exist.
|
|
@@ -3621,6 +3610,10 @@ function setMotionValue(visualElement, key, value) {
|
|
|
3621
3610
|
visualElement.addValue(key, motionDom.motionValue(value));
|
|
3622
3611
|
}
|
|
3623
3612
|
}
|
|
3613
|
+
function resolveFinalValueInKeyframes(v) {
|
|
3614
|
+
// TODO maybe throw if v.length - 1 is placeholder token?
|
|
3615
|
+
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
|
3616
|
+
}
|
|
3624
3617
|
function setTarget(visualElement, definition) {
|
|
3625
3618
|
const resolved = resolveVariant(visualElement, definition);
|
|
3626
3619
|
let { transitionEnd = {}, transition = {}, ...target } = resolved || {};
|
package/dist/cjs/dom.js
CHANGED
|
@@ -345,11 +345,6 @@ const isKeyframesTarget = (v) => {
|
|
|
345
345
|
return Array.isArray(v);
|
|
346
346
|
};
|
|
347
347
|
|
|
348
|
-
const resolveFinalValueInKeyframes = (v) => {
|
|
349
|
-
// TODO maybe throw if v.length - 1 is placeholder token?
|
|
350
|
-
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
|
351
|
-
};
|
|
352
|
-
|
|
353
348
|
function getValueState(visualElement) {
|
|
354
349
|
const state = [{}, {}];
|
|
355
350
|
visualElement?.values.forEach((value, key) => {
|
|
@@ -402,6 +397,10 @@ function setMotionValue(visualElement, key, value) {
|
|
|
402
397
|
visualElement.addValue(key, motionDom.motionValue(value));
|
|
403
398
|
}
|
|
404
399
|
}
|
|
400
|
+
function resolveFinalValueInKeyframes(v) {
|
|
401
|
+
// TODO maybe throw if v.length - 1 is placeholder token?
|
|
402
|
+
return isKeyframesTarget(v) ? v[v.length - 1] || 0 : v;
|
|
403
|
+
}
|
|
405
404
|
function setTarget(visualElement, definition) {
|
|
406
405
|
const resolved = resolveVariant(visualElement, definition);
|
|
407
406
|
let { transitionEnd = {}, transition = {}, ...target } = resolved || {};
|
|
@@ -760,7 +759,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
760
759
|
* and warn against mismatches.
|
|
761
760
|
*/
|
|
762
761
|
if (process.env.NODE_ENV === "development") {
|
|
763
|
-
motionUtils.warnOnce(nextValue.version === "12.
|
|
762
|
+
motionUtils.warnOnce(nextValue.version === "12.8.0", `Attempting to mix Motion versions ${nextValue.version} with 12.8.0 may not work as expected.`);
|
|
764
763
|
}
|
|
765
764
|
}
|
|
766
765
|
else if (isMotionValue(prevValue)) {
|
|
@@ -2589,24 +2588,6 @@ function distance2D(a, b) {
|
|
|
2589
2588
|
return Math.sqrt(xDelta ** 2 + yDelta ** 2);
|
|
2590
2589
|
}
|
|
2591
2590
|
|
|
2592
|
-
const isCustomValueType = (v) => {
|
|
2593
|
-
return v && typeof v === "object" && v.mix;
|
|
2594
|
-
};
|
|
2595
|
-
const getMixer = (v) => (isCustomValueType(v) ? v.mix : undefined);
|
|
2596
|
-
function transform(...args) {
|
|
2597
|
-
const useImmediate = !Array.isArray(args[0]);
|
|
2598
|
-
const argOffset = useImmediate ? 0 : -1;
|
|
2599
|
-
const inputValue = args[0 + argOffset];
|
|
2600
|
-
const inputRange = args[1 + argOffset];
|
|
2601
|
-
const outputRange = args[2 + argOffset];
|
|
2602
|
-
const options = args[3 + argOffset];
|
|
2603
|
-
const interpolator = motionDom.interpolate(inputRange, outputRange, {
|
|
2604
|
-
mixer: getMixer(outputRange[0]),
|
|
2605
|
-
...options,
|
|
2606
|
-
});
|
|
2607
|
-
return useImmediate ? interpolator(inputValue) : interpolator;
|
|
2608
|
-
}
|
|
2609
|
-
|
|
2610
2591
|
exports.animate = animate;
|
|
2611
2592
|
exports.animateMini = animateMini;
|
|
2612
2593
|
exports.createScopedAnimate = createScopedAnimate;
|
|
@@ -2617,7 +2598,6 @@ exports.inView = inView;
|
|
|
2617
2598
|
exports.scroll = scroll;
|
|
2618
2599
|
exports.scrollInfo = scrollInfo;
|
|
2619
2600
|
exports.stagger = stagger;
|
|
2620
|
-
exports.transform = transform;
|
|
2621
2601
|
Object.keys(motionDom).forEach(function (k) {
|
|
2622
2602
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
2623
2603
|
enumerable: true,
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var create = require('./create-
|
|
7
|
+
var create = require('./create-Bv1Fn_mR.js');
|
|
8
8
|
var motionDom = require('motion-dom');
|
|
9
9
|
var motionUtils = require('motion-utils');
|
|
10
10
|
|
|
@@ -636,24 +636,6 @@ function useMotionValue(initial) {
|
|
|
636
636
|
return value;
|
|
637
637
|
}
|
|
638
638
|
|
|
639
|
-
const isCustomValueType = (v) => {
|
|
640
|
-
return v && typeof v === "object" && v.mix;
|
|
641
|
-
};
|
|
642
|
-
const getMixer = (v) => (isCustomValueType(v) ? v.mix : undefined);
|
|
643
|
-
function transform(...args) {
|
|
644
|
-
const useImmediate = !Array.isArray(args[0]);
|
|
645
|
-
const argOffset = useImmediate ? 0 : -1;
|
|
646
|
-
const inputValue = args[0 + argOffset];
|
|
647
|
-
const inputRange = args[1 + argOffset];
|
|
648
|
-
const outputRange = args[2 + argOffset];
|
|
649
|
-
const options = args[3 + argOffset];
|
|
650
|
-
const interpolator = motionDom.interpolate(inputRange, outputRange, {
|
|
651
|
-
mixer: getMixer(outputRange[0]),
|
|
652
|
-
...options,
|
|
653
|
-
});
|
|
654
|
-
return useImmediate ? interpolator(inputValue) : interpolator;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
639
|
function useCombineMotionValues(values, combineValues) {
|
|
658
640
|
/**
|
|
659
641
|
* Initialise the returned motion value. This remains the same between renders.
|
|
@@ -707,7 +689,7 @@ function useTransform(input, inputRangeOrTransformer, outputRange, options) {
|
|
|
707
689
|
}
|
|
708
690
|
const transformer = typeof inputRangeOrTransformer === "function"
|
|
709
691
|
? inputRangeOrTransformer
|
|
710
|
-
: transform(inputRangeOrTransformer, outputRange, options);
|
|
692
|
+
: motionDom.transform(inputRangeOrTransformer, outputRange, options);
|
|
711
693
|
return Array.isArray(input)
|
|
712
694
|
? useListTransform(input, transformer)
|
|
713
695
|
: useListTransform([input], ([latest]) => transformer(latest));
|
|
@@ -3021,7 +3003,6 @@ exports.scroll = scroll;
|
|
|
3021
3003
|
exports.scrollInfo = scrollInfo;
|
|
3022
3004
|
exports.stagger = stagger;
|
|
3023
3005
|
exports.startOptimizedAppearAnimation = startOptimizedAppearAnimation;
|
|
3024
|
-
exports.transform = transform;
|
|
3025
3006
|
exports.unwrapMotionComponent = unwrapMotionComponent;
|
|
3026
3007
|
exports.useAnimate = useAnimate;
|
|
3027
3008
|
exports.useAnimateMini = useAnimateMini;
|
package/dist/cjs/m.js
CHANGED
|
@@ -925,20 +925,13 @@ function useConstant(init) {
|
|
|
925
925
|
return ref.current;
|
|
926
926
|
}
|
|
927
927
|
|
|
928
|
-
const isCustomValue = (v) => {
|
|
929
|
-
return Boolean(v && typeof v === "object" && v.mix && v.toValue);
|
|
930
|
-
};
|
|
931
|
-
|
|
932
928
|
/**
|
|
933
929
|
* If the provided value is a MotionValue, this returns the actual value, otherwise just the value itself
|
|
934
930
|
*
|
|
935
931
|
* TODO: Remove and move to library
|
|
936
932
|
*/
|
|
937
933
|
function resolveMotionValue(value) {
|
|
938
|
-
|
|
939
|
-
return isCustomValue(unwrappedValue)
|
|
940
|
-
? unwrappedValue.toValue()
|
|
941
|
-
: unwrappedValue;
|
|
934
|
+
return isMotionValue(value) ? value.get() : value;
|
|
942
935
|
}
|
|
943
936
|
|
|
944
937
|
function makeState({ scrapeMotionValuesFromProps, createRenderState, onUpdate, }, props, context, presenceContext) {
|
package/dist/dom.d.ts
CHANGED
|
@@ -158,97 +158,4 @@ declare function delayInSeconds(callback: DelayedFunction, timeout: number): ()
|
|
|
158
158
|
declare const distance: (a: number, b: number) => number;
|
|
159
159
|
declare function distance2D(a: Point, b: Point): number;
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
* @public
|
|
163
|
-
*/
|
|
164
|
-
interface TransformOptions<T> {
|
|
165
|
-
/**
|
|
166
|
-
* Clamp values to within the given range. Defaults to `true`
|
|
167
|
-
*
|
|
168
|
-
* @public
|
|
169
|
-
*/
|
|
170
|
-
clamp?: boolean;
|
|
171
|
-
/**
|
|
172
|
-
* Easing functions to use on the interpolations between each value in the input and output ranges.
|
|
173
|
-
*
|
|
174
|
-
* If provided as an array, the array must be one item shorter than the input and output ranges, as the easings apply to the transition **between** each.
|
|
175
|
-
*
|
|
176
|
-
* @public
|
|
177
|
-
*/
|
|
178
|
-
ease?: EasingFunction | EasingFunction[];
|
|
179
|
-
/**
|
|
180
|
-
* Provide a function that can interpolate between any two values in the provided range.
|
|
181
|
-
*
|
|
182
|
-
* @public
|
|
183
|
-
*/
|
|
184
|
-
mixer?: (from: T, to: T) => (v: number) => any;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Transforms numbers into other values by mapping them from an input range to an output range.
|
|
188
|
-
* Returns the type of the input provided.
|
|
189
|
-
*
|
|
190
|
-
* @remarks
|
|
191
|
-
*
|
|
192
|
-
* Given an input range of `[0, 200]` and an output range of
|
|
193
|
-
* `[0, 1]`, this function will return a value between `0` and `1`.
|
|
194
|
-
* The input range must be a linear series of numbers. The output range
|
|
195
|
-
* can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
|
|
196
|
-
* Every value in the output range must be of the same type and in the same format.
|
|
197
|
-
*
|
|
198
|
-
* ```jsx
|
|
199
|
-
* import * as React from "react"
|
|
200
|
-
* import { transform } from "framer-motion"
|
|
201
|
-
*
|
|
202
|
-
* export function MyComponent() {
|
|
203
|
-
* const inputRange = [0, 200]
|
|
204
|
-
* const outputRange = [0, 1]
|
|
205
|
-
* const output = transform(100, inputRange, outputRange)
|
|
206
|
-
*
|
|
207
|
-
* // Returns 0.5
|
|
208
|
-
* return <div>{output}</div>
|
|
209
|
-
* }
|
|
210
|
-
* ```
|
|
211
|
-
*
|
|
212
|
-
* @param inputValue - A number to transform between the input and output ranges.
|
|
213
|
-
* @param inputRange - A linear series of numbers (either all increasing or decreasing).
|
|
214
|
-
* @param outputRange - A series of numbers, colors, strings, or arrays/objects of those. Must be the same length as `inputRange`.
|
|
215
|
-
* @param options - Clamp: Clamp values to within the given range. Defaults to `true`.
|
|
216
|
-
*
|
|
217
|
-
* @public
|
|
218
|
-
*/
|
|
219
|
-
declare function transform<T>(inputValue: number, inputRange: number[], outputRange: T[], options?: TransformOptions<T>): T;
|
|
220
|
-
/**
|
|
221
|
-
*
|
|
222
|
-
* Transforms numbers into other values by mapping them from an input range to an output range.
|
|
223
|
-
*
|
|
224
|
-
* Given an input range of `[0, 200]` and an output range of
|
|
225
|
-
* `[0, 1]`, this function will return a value between `0` and `1`.
|
|
226
|
-
* The input range must be a linear series of numbers. The output range
|
|
227
|
-
* can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
|
|
228
|
-
* Every value in the output range must be of the same type and in the same format.
|
|
229
|
-
*
|
|
230
|
-
* ```jsx
|
|
231
|
-
* import * as React from "react"
|
|
232
|
-
* import { Frame, transform } from "framer"
|
|
233
|
-
*
|
|
234
|
-
* export function MyComponent() {
|
|
235
|
-
* const inputRange = [-200, -100, 100, 200]
|
|
236
|
-
* const outputRange = [0, 1, 1, 0]
|
|
237
|
-
* const convertRange = transform(inputRange, outputRange)
|
|
238
|
-
* const output = convertRange(-150)
|
|
239
|
-
*
|
|
240
|
-
* // Returns 0.5
|
|
241
|
-
* return <div>{output}</div>
|
|
242
|
-
* }
|
|
243
|
-
*
|
|
244
|
-
* ```
|
|
245
|
-
*
|
|
246
|
-
* @param inputRange - A linear series of numbers (either all increasing or decreasing).
|
|
247
|
-
* @param outputRange - A series of numbers, colors or strings. Must be the same length as `inputRange`.
|
|
248
|
-
* @param options - Clamp: clamp values to within the given range. Defaults to `true`.
|
|
249
|
-
*
|
|
250
|
-
* @public
|
|
251
|
-
*/
|
|
252
|
-
declare function transform<T>(inputRange: number[], outputRange: T[], options?: TransformOptions<T>): (inputValue: number) => T;
|
|
253
|
-
|
|
254
|
-
export { type AbsoluteKeyframe, type AnimationSequence, type At, type DOMSegment, type DOMSegmentWithTransition, type DelayedFunction, type MotionValueSegment, type MotionValueSegmentWithTransition, type ObjectSegment, type ObjectSegmentWithTransition, type ObjectTarget, type ResolvedAnimationDefinition, type ResolvedAnimationDefinitions, type Segment, type SequenceLabel, type SequenceLabelWithTime, type SequenceMap, type SequenceOptions, type SequenceTime, type ValueSequence, animate, animateMini, createScopedAnimate, delayInSeconds as delay, distance, distance2D, inView, scroll, scrollInfo, stagger, transform };
|
|
161
|
+
export { type AbsoluteKeyframe, type AnimationSequence, type At, type DOMSegment, type DOMSegmentWithTransition, type DelayedFunction, type MotionValueSegment, type MotionValueSegmentWithTransition, type ObjectSegment, type ObjectSegmentWithTransition, type ObjectTarget, type ResolvedAnimationDefinition, type ResolvedAnimationDefinitions, type Segment, type SequenceLabel, type SequenceLabelWithTime, type SequenceMap, type SequenceOptions, type SequenceTime, type ValueSequence, animate, animateMini, createScopedAnimate, delayInSeconds as delay, distance, distance2D, inView, scroll, scrollInfo, stagger };
|