bash
npm install @hua-labs/huatsx
import { useScrollDirection } from "@hua-labs/hua/framework";tsx
import { useScrollDirection } from "@hua-labs/hua/framework";
const { direction, scrollY, isScrollingUp, isScrollingDown } = useScrollDirection({
threshold: 10, // Minimum scroll delta
throttle: 100, // Throttle in ms
});
return (
<header className={isScrollingDown ? 'hidden' : 'visible'}>
{/* Header hides on scroll down, shows on scroll up */}
</header>
);0px
none
Smart Header↑
1
2
3
4
5
6
7
8
9
10
↕
| threshold | number | 10 | |
| throttle | number | 100 | |
| targetRef | RefObject | window | |
| initialDirection | "up" | "down" | "none" | "none" |
| direction | "up" | "down" | "none" | |
| scrollY | number | |
| isScrollingUp | boolean | |
| isScrollingDown | boolean | |
| delta | number | |
| progress | number | |
| mounted | boolean |