Skip to content

useGestureMotion

@hua-labs/hua/motion

bash
npm install @hua-labs/hua
tsx
import { useGestureMotion } from "@hua-labs/hua/framework";

tsx
const { ref, motionStyle, isActive } = useGestureMotion({
  gestureType: "hover",
  duration: 200,
});

return (
  <div ref={ref} style={motionStyle} className="card">
    {isActive ? 'Hovering!' : 'Hover me'}
  </div>
);

gestureType*"hover" | "drag" | "pinch" | "swipe" | "tilt"-Gesture type that triggers motion
durationnumber300Animation duration in milliseconds
easingstring"ease-out"CSS easing function
sensitivitynumber1Gesture sensitivity multiplier
enabledbooleantrueEnable/disable gesture detection
onGestureStart() => void-Callback when gesture begins
onGestureEnd() => void-Callback when gesture ends

refRefObject<HTMLElement | null>Ref to attach to target element
motionStyleCSSPropertiesAnimated CSS style based on gesture
isActivebooleanWhether gesture is active
gestureStateGestureStateCurrent gesture state (x, y, scale, rotation, delta)