All files / src/value/utils resolve-motion-value.ts

100% Statements 5/5
100% Branches 4/4
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  39x   39x                 39x     399x 399x        
import { MotionValue } from ".."
import { isCustomValue } from "../../utils/resolve-value"
import { CustomValueType } from "../../types"
import { isMotionValue } from "./is-motion-value"
 
/**
 * If the provided value is a MotionValue, this returns the actual value, otherwise just the value itself
 *
 * TODO: Remove and move to library
 *
 * @internal
 */
export function resolveMotionValue(
    value?: string | number | CustomValueType | MotionValue
): string | number {
    const unwrappedValue = isMotionValue(value) ? value.get() : value
    return isCustomValue(unwrappedValue)
        ? unwrappedValue.toValue()
        : unwrappedValue
}