framer-motion
Version:
An open source and production-ready motion library for React on the web
62 lines (59 loc) • 1.33 kB
text/typescript
import { gestureProps } from "../features/gestures"
import { MotionProps } from "../types"
/**
* A list of all valid MotionProps.
*
* @internalremarks
* This doesn't throw if a `MotionProp` name is missing - it should.
*/
const validMotionProps = new Set<keyof MotionProps>([
"initial",
"animate",
"exit",
"style",
"variants",
"transition",
"transformTemplate",
"transformValues",
"custom",
"inherit",
"layout",
"layoutId",
"onLayoutAnimationComplete",
"onViewportBoxUpdate",
"onLayoutMeasure",
"onBeforeLayoutMeasure",
"onAnimationStart",
"onAnimationComplete",
"onUpdate",
"onDragStart",
"onDrag",
"onDragEnd",
"onMeasureDragConstraints",
"onDirectionLock",
"onDragTransitionEnd",
"drag",
"dragControls",
"dragListener",
"dragConstraints",
"dragDirectionLock",
"_dragX",
"_dragY",
"dragElastic",
"dragMomentum",
"dragPropagation",
"dragTransition",
"whileDrag",
...gestureProps,
])
/**
* Check whether a prop name is a valid `MotionProp` key.
*
* @param key - Name of the property to check
* @returns `true` is key is a valid `MotionProp`.
*
* @public
*/
export function isValidMotionProp(key: string) {
return validMotionProps.has(key as keyof MotionProps)
}