motion-v 2.1.0 → 2.2.1

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.
@@ -48,7 +48,8 @@ var MotionState = class {
48
48
  invariant(Boolean(element), "Animation state must be mounted with valid Element");
49
49
  mountedStates.set(element, this);
50
50
  this.element = element;
51
- element.setAttribute(motionGlobalConfig.motionAttribute, this.options.presenceContext?.presenceId ?? "");
51
+ const presenceId = this.options.presenceContext?.presenceId;
52
+ if (presenceId !== void 0) element.setAttribute(motionGlobalConfig.motionAttribute, presenceId);
52
53
  this.visualElement?.mount(element);
53
54
  this.updateFeatures();
54
55
  }
@@ -1,5 +1,5 @@
1
1
  import { cancelFrame, frame, motionValue } from "motion-dom";
2
- import { onUnmounted } from "vue";
2
+ import { getCurrentInstance, onUnmounted } from "vue";
3
3
  function useCombineMotionValues(combineValues) {
4
4
  const value = motionValue(combineValues());
5
5
  const updateValue = () => value.set(combineValues());
@@ -12,7 +12,7 @@ function useCombineMotionValues(combineValues) {
12
12
  subscriptions.forEach((unsubscribe$1) => unsubscribe$1());
13
13
  cancelFrame(updateValue);
14
14
  };
15
- onUnmounted(() => {
15
+ if (getCurrentInstance()) onUnmounted(() => {
16
16
  unsubscribe();
17
17
  });
18
18
  return {
@@ -3,5 +3,6 @@ import { MotionValue } from 'framer-motion/dom';
3
3
  import { FollowValueOptions, SpringOptions } from 'motion-dom';
4
4
  type AnyResolvedKeyframe = string | number;
5
5
  export declare function useFollowValue<T extends AnyResolvedKeyframe>(source: T | MotionValue<T>, options?: MaybeRef<FollowValueOptions>): MotionValue<T>;
6
- export declare function useSpring(source: MotionValue<string> | MotionValue<number> | number, config?: MaybeRef<SpringOptions>): MotionValue<string | number>;
6
+ export declare function useSpring(source: MotionValue<string> | string, config?: MaybeRef<SpringOptions>): MotionValue<string>;
7
+ export declare function useSpring(source: MotionValue<number> | number, config?: MaybeRef<SpringOptions>): MotionValue<number>;
7
8
  export {};
@@ -5,12 +5,12 @@ import { isRef, watch } from "vue";
5
5
  function useTransform(input, inputRangeOrTransformer, outputRange, options) {
6
6
  if (typeof input === "function") return useComputed(input);
7
7
  if (outputRange && !Array.isArray(outputRange) && typeof outputRange === "object") {
8
- const result = {};
8
+ const result$1 = {};
9
9
  for (const key in outputRange) if (Object.prototype.hasOwnProperty.call(outputRange, key)) {
10
10
  const keyOutputRange = outputRange[key];
11
- result[key] = useTransform(input, inputRangeOrTransformer, keyOutputRange, options);
11
+ result$1[key] = useTransform(input, inputRangeOrTransformer, keyOutputRange, options);
12
12
  }
13
- return result;
13
+ return result$1;
14
14
  }
15
15
  let inputValues;
16
16
  let transformer;
@@ -32,9 +32,23 @@ function useTransform(input, inputRangeOrTransformer, outputRange, options) {
32
32
  transformer = transform(inputRangeOrTransformer, outputRange, options);
33
33
  inputValues = Array.isArray(input) ? input : [input];
34
34
  }
35
- return Array.isArray(input) ? useListTransform(inputValues, transformer) : useListTransform(inputValues, (values) => {
35
+ const result = Array.isArray(input) ? useListTransform(inputValues, transformer) : useListTransform(inputValues, (values) => {
36
36
  return transformer(values[0]);
37
37
  });
38
+ if (!Array.isArray(input)) {
39
+ const inputAccelerate = input.accelerate;
40
+ if (inputAccelerate && !inputAccelerate.isTransformed && typeof inputRangeOrTransformer !== "function" && Array.isArray(outputRange) && options?.clamp !== false) {
41
+ const resolvedInputRange = isRef(inputRangeOrTransformer) ? inputRangeOrTransformer.value : inputRangeOrTransformer;
42
+ result.accelerate = {
43
+ ...inputAccelerate,
44
+ times: resolvedInputRange,
45
+ keyframes: outputRange,
46
+ isTransformed: true,
47
+ ...options?.ease ? { ease: options.ease } : {}
48
+ };
49
+ }
50
+ }
51
+ return result;
38
52
  }
39
53
  function useListTransform(values, transformer) {
40
54
  const latest = [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "motion-v",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "2.2.1",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "MIT",