Skip to content

useSlideDown

@hua-labs/hua/motion

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

tsx
const slideDown = useSlideDown({ duration: 700, delay: 100 });

return (
  <div ref={slideDown.ref} style={slideDown.style}>
    Slides in from top to bottom
  </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
onComplete() => void-Callback when animation completes
onStart() => void-Callback when animation starts
onStop() => void-Callback when animation is stopped
onReset() => void-Callback when animation is reset

refRefObject<T | null>Ref to attach to element
styleCSSPropertiesAnimated style (translateY + 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