motion-v 0.11.3 → 0.12.0-beta.2
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 +47 -71
- package/dist/es/components/animate-presence/AnimatePresence.d.ts +1 -4
- package/dist/es/components/animate-presence/AnimatePresence.vue.mjs +10 -6
- package/dist/es/components/animate-presence/types.d.ts +1 -2
- package/dist/es/components/reorder/Item.d.ts +15 -67
- package/dist/es/components/reorder/Item.vue.mjs +9 -3
- package/dist/es/components/reorder/index.d.ts +8940 -11
- package/dist/es/components/reorder/index.mjs +2 -2
- package/dist/es/features/feature-manager.mjs +0 -2
- package/dist/es/features/gestures/types.d.ts +2 -4
- package/dist/es/features/index.d.ts +0 -1
- package/dist/es/features/layout/layout.mjs +0 -4
- package/dist/es/state/animate-updates.mjs +21 -24
- package/dist/es/state/motion-state.mjs +3 -0
- package/dist/es/state/utils.mjs +0 -4
- package/dist/es/types/state.d.ts +4 -1
- package/dist/es/value/use-spring.d.ts +2 -2
- package/dist/es/value/use-transform.d.ts +2 -1
- package/package.json +1 -1
- package/dist/es/features/svg.d.ts +0 -5
- package/dist/es/features/svg.mjs +0 -31
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SVGFeature } from "./svg.mjs";
|
|
2
1
|
import { LayoutFeature } from "./layout/layout.mjs";
|
|
3
2
|
import { PanGesture } from "./gestures/pan/index.mjs";
|
|
4
3
|
import { AnimationFeature } from "./animation/animation.mjs";
|
|
@@ -15,7 +14,6 @@ class FeatureManager {
|
|
|
15
14
|
new HoverGesture(state),
|
|
16
15
|
new PressGesture(state),
|
|
17
16
|
new InViewGesture(state),
|
|
18
|
-
new SVGFeature(state),
|
|
19
17
|
new LayoutFeature(state),
|
|
20
18
|
new ProjectionFeature(state),
|
|
21
19
|
new PanGesture(state),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Options } from '../../types';
|
|
2
|
+
import { InertiaOptions } from 'framer-motion';
|
|
2
3
|
export interface StateHandlers {
|
|
3
4
|
enable: VoidFunction;
|
|
4
5
|
disable: VoidFunction;
|
|
@@ -17,8 +18,5 @@ export interface DragOptions {
|
|
|
17
18
|
dragSnapToOrigin?: boolean;
|
|
18
19
|
dragElastic?: number;
|
|
19
20
|
dragMomentum?: boolean;
|
|
20
|
-
dragTransition?:
|
|
21
|
-
power?: number;
|
|
22
|
-
timeConstant?: number;
|
|
23
|
-
};
|
|
21
|
+
dragTransition?: InertiaOptions;
|
|
24
22
|
}
|
|
@@ -45,16 +45,12 @@ class LayoutFeature extends Feature {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
unmount() {
|
|
48
|
-
var _a, _b;
|
|
49
48
|
const layoutGroup = this.state.options.layoutGroup;
|
|
50
49
|
const projection = this.state.visualElement.projection;
|
|
51
50
|
if (projection) {
|
|
52
51
|
if (layoutGroup == null ? void 0 : layoutGroup.group) {
|
|
53
52
|
layoutGroup.group.remove(projection);
|
|
54
53
|
}
|
|
55
|
-
if ((_b = (_a = projection.getStack()) == null ? void 0 : _a.lead) == null ? void 0 : _b.animationProgress) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
54
|
this.didUpdate();
|
|
59
55
|
}
|
|
60
56
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveVariant,
|
|
1
|
+
import { resolveVariant, hasChanged } from "./utils.mjs";
|
|
2
2
|
import { style } from "./style.mjs";
|
|
3
3
|
import { transformResetValue } from "./transform.mjs";
|
|
4
4
|
import { motionEvent } from "./event.mjs";
|
|
@@ -23,9 +23,9 @@ function animateUpdates({
|
|
|
23
23
|
if (directAnimate)
|
|
24
24
|
animationOptions = resolveDirectAnimation.call(this, directAnimate, directTransition, animationOptions);
|
|
25
25
|
else
|
|
26
|
-
animationOptions = resolveStateAnimation.call(this, controlActiveState
|
|
26
|
+
animationOptions = resolveStateAnimation.call(this, controlActiveState);
|
|
27
27
|
const factories = createAnimationFactories.call(this, prevTarget, animationOptions, controlDelay);
|
|
28
|
-
const { getChildAnimations, childAnimations } = setupChildAnimations.call(this,
|
|
28
|
+
const { getChildAnimations, childAnimations } = setupChildAnimations.call(this, animationOptions, this.activeStates, isFallback);
|
|
29
29
|
return executeAnimations.call(this, {
|
|
30
30
|
factories,
|
|
31
31
|
getChildAnimations,
|
|
@@ -39,21 +39,18 @@ function resolveDirectAnimation(directAnimate, directTransition) {
|
|
|
39
39
|
const variant = resolveVariant(directAnimate, this.options.variants, this.options.custom);
|
|
40
40
|
if (!variant)
|
|
41
41
|
return {};
|
|
42
|
-
const transition =
|
|
43
|
-
const animationOptions = {};
|
|
42
|
+
const transition = variant.transition || directTransition || this.options.transition || {};
|
|
44
43
|
Object.entries(variant).forEach(([key, value]) => {
|
|
45
44
|
if (key === "transition")
|
|
46
45
|
return;
|
|
47
46
|
this.target[key] = value;
|
|
48
|
-
animationOptions[key] = getOptions(transition, key);
|
|
49
47
|
});
|
|
50
|
-
return
|
|
48
|
+
return transition;
|
|
51
49
|
}
|
|
52
|
-
function resolveStateAnimation(controlActiveState
|
|
50
|
+
function resolveStateAnimation(controlActiveState) {
|
|
53
51
|
if (controlActiveState)
|
|
54
52
|
this.activeStates = { ...this.activeStates, ...controlActiveState };
|
|
55
|
-
|
|
56
|
-
let variantTransition = {};
|
|
53
|
+
let variantTransition = this.options.transition;
|
|
57
54
|
let variant = {};
|
|
58
55
|
STATE_TYPES.forEach((name) => {
|
|
59
56
|
if (!this.activeStates[name] || isAnimationControls(this.options[name]))
|
|
@@ -67,17 +64,15 @@ function resolveStateAnimation(controlActiveState, transition) {
|
|
|
67
64
|
if (!resolvedVariant)
|
|
68
65
|
return;
|
|
69
66
|
if (name !== "initial")
|
|
70
|
-
variantTransition = resolvedVariant.transition || this.options.transition;
|
|
67
|
+
variantTransition = resolvedVariant.transition || this.options.transition || {};
|
|
71
68
|
variant = Object.assign(variant, resolvedVariant);
|
|
72
69
|
});
|
|
73
|
-
Object.assign(transition, variantTransition);
|
|
74
70
|
Object.entries(variant).forEach(([key, value]) => {
|
|
75
71
|
if (key === "transition")
|
|
76
72
|
return;
|
|
77
73
|
this.target[key] = value;
|
|
78
|
-
transitionOptions[key] = getOptions(transition, key);
|
|
79
74
|
});
|
|
80
|
-
return
|
|
75
|
+
return variantTransition;
|
|
81
76
|
}
|
|
82
77
|
function createAnimationFactories(prevTarget, animationOptions, controlDelay) {
|
|
83
78
|
const factories = [];
|
|
@@ -86,16 +81,18 @@ function createAnimationFactories(prevTarget, animationOptions, controlDelay) {
|
|
|
86
81
|
if (!hasChanged(prevTarget[key], this.target[key]))
|
|
87
82
|
return;
|
|
88
83
|
(_a = this.baseTarget)[key] ?? (_a[key] = style.get(this.element, key));
|
|
89
|
-
const keyValue = this.target[key] === "none" ? transformResetValue[key] : this.target[key];
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
84
|
+
const keyValue = this.target[key] === "none" && isDef(transformResetValue[key]) ? transformResetValue[key] : this.target[key];
|
|
85
|
+
factories.push(() => {
|
|
86
|
+
var _a2;
|
|
87
|
+
return animate(
|
|
88
|
+
this.element,
|
|
89
|
+
{ [key]: keyValue },
|
|
90
|
+
{
|
|
91
|
+
...animationOptions,
|
|
92
|
+
delay: (((_a2 = animationOptions == null ? void 0 : animationOptions[key]) == null ? void 0 : _a2.delay) || (animationOptions == null ? void 0 : animationOptions.delay) || 0) + controlDelay
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
});
|
|
99
96
|
});
|
|
100
97
|
return factories;
|
|
101
98
|
}
|
|
@@ -112,6 +112,9 @@ class MotionState {
|
|
|
112
112
|
this.updateOptions();
|
|
113
113
|
this.featureManager.mount();
|
|
114
114
|
if (!notAnimate && this.options.animate) {
|
|
115
|
+
if (this.visualElement.type === "svg") {
|
|
116
|
+
this.visualElement.updateDimensions();
|
|
117
|
+
}
|
|
115
118
|
this.startAnimation();
|
|
116
119
|
}
|
|
117
120
|
if (this.options.layoutId) {
|
package/dist/es/state/utils.mjs
CHANGED
|
@@ -28,9 +28,6 @@ function shallowCompare(next, prev) {
|
|
|
28
28
|
}
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
31
|
-
function getOptions(options, key) {
|
|
32
|
-
return options[key] ? { ...options, ...options[key], [key]: void 0 } : { ...options };
|
|
33
|
-
}
|
|
34
31
|
function isCssVar(name) {
|
|
35
32
|
return name == null ? void 0 : name.startsWith("--");
|
|
36
33
|
}
|
|
@@ -124,7 +121,6 @@ function isAnimateChanged(oldOptions, newOptions) {
|
|
|
124
121
|
return oldAnimate !== newAnimate;
|
|
125
122
|
}
|
|
126
123
|
export {
|
|
127
|
-
getOptions,
|
|
128
124
|
hasChanged,
|
|
129
125
|
isAnimateChanged,
|
|
130
126
|
isCssVar,
|
package/dist/es/types/state.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ type AnimationPlaybackControls = ReturnType<typeof animate>;
|
|
|
16
16
|
export type TargetResolver = (custom: any, current: Target, velocity: Target) => TargetAndTransition | string;
|
|
17
17
|
export interface Variant extends DOMKeyframesDefinition {
|
|
18
18
|
transition?: $Transition;
|
|
19
|
+
attrX?: DOMKeyframesDefinition['x'];
|
|
20
|
+
attrY?: DOMKeyframesDefinition['y'];
|
|
21
|
+
attrScale?: DOMKeyframesDefinition['scale'];
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
24
|
* Either a string, or array of strings, that reference variants defined via the `variants` prop.
|
|
@@ -34,7 +37,7 @@ export interface DragOptions {
|
|
|
34
37
|
}
|
|
35
38
|
type TransformPropertiesWithoutTransition = Omit<TransformProperties, 'transition'>;
|
|
36
39
|
export type MotionStyle = Partial<{
|
|
37
|
-
[K in keyof
|
|
40
|
+
[K in keyof Omit<Variant & TransformPropertiesWithoutTransition, 'attrX' | 'attrY' | 'attrScale'>]: string | number | undefined | MotionValue;
|
|
38
41
|
}>;
|
|
39
42
|
export type ElementType = keyof IntrinsicElementAttributes;
|
|
40
43
|
export interface Options<T = any> extends LayoutOptions, PressProps, HoverProps, InViewProps, DragProps, PanProps, FocusProps {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
2
|
import { MotionValue } from 'framer-motion/dom';
|
|
3
3
|
import { SpringOptions } from 'framer-motion';
|
|
4
|
-
export declare function useSpring(source: MotionValue<string> | MotionValue<number> | number, config?: SpringOptions |
|
|
4
|
+
export declare function useSpring(source: MotionValue<string> | MotionValue<number> | number, config?: SpringOptions | Ref<SpringOptions>): MotionValue<number>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TransformOptions } from '../types';
|
|
2
2
|
import { MotionValue } from 'framer-motion/dom';
|
|
3
|
+
import { MaybeRef } from 'vue';
|
|
3
4
|
type InputRange = number[];
|
|
4
5
|
type SingleTransformer<I, O> = (input: I) => O;
|
|
5
6
|
type MultiTransformer<I, O> = (input: I[]) => O;
|
|
@@ -51,7 +52,7 @@ type MultiTransformer<I, O> = (input: I[]) => O;
|
|
|
51
52
|
*
|
|
52
53
|
* @public
|
|
53
54
|
*/
|
|
54
|
-
export declare function useTransform<I, O>(value: MotionValue<number>, inputRange: InputRange
|
|
55
|
+
export declare function useTransform<I, O>(value: MotionValue<number>, inputRange: InputRange | MaybeRef<InputRange>, outputRange: O[], options?: TransformOptions<O>): MotionValue<O>;
|
|
55
56
|
export declare function useTransform<I, O>(transformer: () => O): MotionValue<O>;
|
|
56
57
|
export declare function useTransform<I, O>(input: MotionValue<I>, transformer: SingleTransformer<I, O>): MotionValue<O>;
|
|
57
58
|
export declare function useTransform<I, O>(input: MotionValue<string>[] | MotionValue<number>[] | MotionValue<string | number>[], transformer: MultiTransformer<I, O>): MotionValue<O>;
|
package/package.json
CHANGED
package/dist/es/features/svg.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Feature } from "./feature.mjs";
|
|
2
|
-
import { frame } from "../external/.pnpm/framer-motion@12.4.10/external/framer-motion/dist/es/frameloop/frame.mjs";
|
|
3
|
-
function isSVGElement(element) {
|
|
4
|
-
return element instanceof SVGElement && element.tagName !== "svg";
|
|
5
|
-
}
|
|
6
|
-
class SVGFeature extends Feature {
|
|
7
|
-
mount() {
|
|
8
|
-
const instance = this.state.element;
|
|
9
|
-
if (!isSVGElement(instance)) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const visualElement = this.state.visualElement;
|
|
13
|
-
frame.read(() => {
|
|
14
|
-
try {
|
|
15
|
-
visualElement.renderState.dimensions = typeof instance.getBBox === "function" ? instance.getBBox() : instance.getBoundingClientRect();
|
|
16
|
-
} catch (e) {
|
|
17
|
-
visualElement.renderState.dimensions = {
|
|
18
|
-
x: 0,
|
|
19
|
-
y: 0,
|
|
20
|
-
width: 0,
|
|
21
|
-
height: 0
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
unmount() {
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
SVGFeature
|
|
31
|
-
};
|