Beta Status
This library is still in early beta and the API is subject to change and may get daily breaking changes. If the docs and the package disagree, prefer the package and open an issue on GitHub or send a pull request with a fix.
Gestures
Gesture props give you hover, tap, focus, in-view, and pan state on motion components.
Props
whileHover:target object | variant label | string[]onHoverStart:() => voidonHoverEnd:() => voidwhileTap:target object | variant label | string[]onTapStart:(event, info) => voidonTap:(event, info) => voidonTapCancel:(event, info) => voidglobalTapTarget:booleanwhileFocus:target object | variant label | string[]whileInView:target object | variant label | string[]viewport:{ root?: Element | Document | null; once?: boolean; margin?: string; amount?: "some" | "all" | number }onViewportEnter:(entry) => voidonViewportLeave:(entry) => voidonPanSessionStart:(event, info) => voidonPanStart:(event, info) => voidonPan:(event, info) => voidonPanEnd:(event, info) => void
Notes
viewport.roottakes a directElementorDocumentreference in Solid.- Pan callback info includes
point,delta,offset, andvelocity. - Gesture precedence is drag, pan, tap, then hover.
Example
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
onTap={() => console.log("tap")}
/>
Gestures