Skip to content

useSmartMotion

@hua-labs/hua/motion

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

tsx
const card = useSmartMotion({
  type: "card",
  entrance: "slideUp",
  hover: true,
  delay: 200,
});

return (
  <div ref={card.ref} style={card.style} className="card">
    Smart motion card
  </div>
);

type"hero" | "title" | "button" | "card" | "text" | "image"-Element type for preset behavior
entrance"fadeIn" | "slideUp" | "slideLeft" | "slideRight" | "scaleIn" | "bounceIn"-Entrance animation type
hoverboolean-Enable hover effects
clickboolean-Enable click effects
delaynumber0Animation delay in milliseconds
durationnumber700Animation duration in milliseconds
thresholdnumber0.1Viewport intersection threshold (0-1)
autoLanguageSyncbooleanfalseRe-trigger animation on language change

refRefObject<T | null>Ref to attach to element
styleCSSPropertiesAnimated style object
isVisiblebooleanWhether element is in viewport
isHoveredbooleanWhether element is hovered
isClickedbooleanWhether element is clicked