Skip to content

useSlideLeft

@hua-labs/hua/motion

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

tsx
const slideLeft = useSlideLeft({ duration: 700, delay: 100 });

return (
  <div ref={slideLeft.ref} style={slideLeft.style}>
    Slides in from right to left
  </div>
);

durationnumber700Animation duration in milliseconds
delaynumber0Delay before animation starts
distancenumber50Slide distance in pixels
thresholdnumber0.1Viewport intersection threshold (0-1)
triggerOncebooleantrueOnly trigger once
easingstring"ease-out"Easing function
autoStartbooleantrueAuto start on viewport entry

refRefObject<T | null>Ref to attach to element
styleCSSPropertiesAnimated style (translateX + opacity)
isVisiblebooleanWhether element is in viewport
isAnimatingbooleanWhether animation is in progress
progressnumberAnimation progress (0-1)
start() => voidStart animation
stop() => voidStop animation
reset() => voidReset to initial state