Skip to content

useScaleIn

@hua-labs/hua/motion

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

tsx
const scaleIn = useScaleIn({ duration: 700, delay: 100 });

return (
  <div ref={scaleIn.ref} style={scaleIn.style}>
    Content scales in when visible
  </div>
);

0 → 1
scale: 0
0.5 → 1
scale: 0.5
0.8 → 1
scale: 0.8

initialScalenumber0Initial scale value
targetScalenumber1Target scale value
durationnumber700Animation duration in milliseconds
delaynumber0Delay before animation starts
thresholdnumber0.1Viewport intersection threshold (0-1)
triggerOncebooleantrueOnly trigger animation once
easingstring"ease-out"CSS 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
styleCSSPropertiesStyle with transform: scale() and 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

tsx
// Start from half size
const scaleIn = useScaleIn({
  initialScale: 0.5,
  duration: 500,
  easing: "ease-in-out",
});

// Start from zero (dramatic effect)
const popIn = useScaleIn({
  initialScale: 0,
  targetScale: 1,
  duration: 300,
});