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.
@@ -3,8 +3,8 @@ import _sfc_main$1 from "./Item.vue.mjs";
3
3
  const ReorderGroup = _sfc_main;
4
4
  const ReorderItem = _sfc_main$1;
5
5
  const Reorder = {
6
- Group: ReorderGroup,
7
- Item: ReorderItem
6
+ Group: _sfc_main,
7
+ Item: _sfc_main$1
8
8
  };
9
9
  export {
10
10
  Reorder,
@@ -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
  }
@@ -1,6 +1,5 @@
1
1
  export * from './feature';
2
2
  export * from './gestures';
3
- export * from './svg';
4
3
  export * from './layout/layout';
5
4
  export * from './gestures/pan';
6
5
  export * from './feature-manager';
@@ -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, getOptions, hasChanged } from "./utils.mjs";
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, transition);
26
+ animationOptions = resolveStateAnimation.call(this, controlActiveState);
27
27
  const factories = createAnimationFactories.call(this, prevTarget, animationOptions, controlDelay);
28
- const { getChildAnimations, childAnimations } = setupChildAnimations.call(this, transition, this.activeStates, isFallback);
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 = { ...this.options.transition, ...directTransition || variant.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 animationOptions;
48
+ return transition;
51
49
  }
52
- function resolveStateAnimation(controlActiveState, transition) {
50
+ function resolveStateAnimation(controlActiveState) {
53
51
  if (controlActiveState)
54
52
  this.activeStates = { ...this.activeStates, ...controlActiveState };
55
- const transitionOptions = {};
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 transitionOptions;
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
- const targetTransition = animationOptions[key];
91
- factories.push(() => animate(
92
- this.element,
93
- { [key]: keyValue },
94
- {
95
- ...targetTransition,
96
- delay: ((targetTransition == null ? void 0 : targetTransition.delay) || 0) + controlDelay
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) {
@@ -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,
@@ -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 (Variant & TransformPropertiesWithoutTransition)]: string | number | undefined | MotionValue;
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 { ComputedRef, Ref } from 'vue';
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 | ComputedRef<SpringOptions> | Ref<SpringOptions>): MotionValue<number>;
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, outputRange: O[], options?: TransformOptions<O>): MotionValue<O>;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-v",
3
- "version": "0.11.3",
3
+ "version": "0.12.0-beta.2",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -1,5 +0,0 @@
1
- import { Feature } from './feature';
2
- export declare class SVGFeature extends Feature {
3
- mount(): void;
4
- unmount(): void;
5
- }
@@ -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
- };