useUnifiedMotion
@hua-labs/hua/motion
bash
npm install @hua-labs/huatsx
import { useUnifiedMotion } from "@hua-labs/hua/framework";tsx
// useMotion from hua wraps this hook
import { useUnifiedMotion } from "@hua-labs/motion-core";
const motion = useUnifiedMotion({
type: "fadeIn",
duration: 600,
autoStart: false,
});
return (
<div ref={motion.ref} style={motion.style}>
Unified motion
</div>
);| type* | "fadeIn" | "slideUp" | "slideLeft" | "slideRight" | "scaleIn" | "bounceIn" | - | Motion type to dispatch |
| duration | number | 600 | Animation duration in milliseconds |
| delay | number | 0 | Delay before animation starts |
| autoStart | boolean | false | Start animation automatically |
| easing | string | "ease-out" | Easing function |
| threshold | number | 0.1 | Viewport intersection threshold |
| triggerOnce | boolean | true | Only trigger animation once |
| distance | number | 50 | Slide distance in pixels (for slide types) |
| ref | RefObject<T | null> | Ref to attach to element |
| style | CSSProperties | Animated style via CSS transition (single hook, no multi-hook overhead) |
| isVisible | boolean | Whether element is in viewport |
| isAnimating | boolean | Whether animation is in progress |
| progress | number | Animation progress (0-1) |
| start | () => void | Start animation |
| stop | () => void | Stop animation |
| reset | () => void | Reset to initial state |