API Reference
useHideOnScroll Hook​
Hook Configuration
The useHideOnScroll
hook provides a simple interface for creating scroll-based hide/show animations. It returns an object containing animation styles and control methods.
Configuration Options​
Option | Type | Default | Description |
---|---|---|---|
height | number | - | Required. Height of the component to animate |
duration | number | 300 | Animation duration in milliseconds |
threshold | number | 10 | Minimum scroll distance to trigger hide/show |
scrollDirection | ScrollDirection | DOWN | Whether to hide when scrolling down |
hideDirection | HideDirection | HideDirection.DOWN | Direction to hide the component |
Return Value​
The hook returns an object with the following properties:
Property | Type | Description |
---|---|---|
animatedStyle | object | Animated style object to be applied to your component |
scrollY | Animated.Value | The scroll position value |
isVisible | boolean | Current visibility state of the component |
show | () => void | Method to show the component |
hide | () => void | Method to hide the component |
toggle | () => void | Method to toggle component visibility |
onScroll | (event: NativeSyntheticEvent<NativeScrollEvent>) => void | Scroll event handler |
ScrollDirection Enum​
Direction Configuration
Use the ScrollDirection enum to specify which direction your component should hide in.
enum ScrollDirection {
UP = 'UP',
DOWN = 'DOWN'
}
HideDirection Enum​
Direction Configuration
Use the HideDirection enum to specify which direction your component should hide in.
enum HideDirection {
UP = 'UP',
DOWN = 'DOWN'
}