motion-v 2.1.0 → 2.2.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.
|
@@ -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 {
|
|
@@ -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
|
-
|
|
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 = [];
|