All files / src/context/MotionContext utils.ts

100% Statements 6/6
100% Branches 10/10
100% Functions 1/1
100% Lines 6/6

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 22 23 24    34x         34x       1420x 564x 282x               1138x    
import { MotionContextProps } from "."
import { MotionProps } from "../../motion/types"
import {
    checkIfControllingVariants,
    isVariantLabel,
} from "../../render/utils/variants"
 
export function getCurrentTreeVariants(
    props: MotionProps,
    context: MotionContextProps
): MotionContextProps {
    if (checkIfControllingVariants(props)) {
        const { initial, animate } = props
        return {
            initial:
                initial === false || isVariantLabel(initial)
                    ? (initial as any)
                    : undefined,
            animate: isVariantLabel(animate) ? animate : undefined,
        }
    }
    return props.inherit !== false ? context : {}
}