Skip to main content
Version: 1.x

useScrollManager

Hook-level API for managing a custom scrollable. This is the hook equivalent of HeaderMotion.ScrollManager.

Prefer createHeaderMotionScrollable() for most cases.

Signature

function useScrollManager(
scrollId?: string,
options?: UseScrollManagerOptions
): ScrollManagerConfig;

Parameters

ParameterTypeDescription
scrollIdstringUnique identifier for multi-scroll setups.
options.animatedRefAnimatedRefExternal animated ref.
options.refreshControlReactElementRefresh control element.
options.refreshingbooleanWhether refresh is active.
options.onRefresh() => voidRefresh callback.
options.progressViewOffsetnumberCustom refresh indicator offset.
options.onScrollscroll handlerConsumer scroll handler (JS or worklet).
options.onScrollBeginDragcallbackDrag begin handler.
options.onScrollEndDragcallbackDrag end handler.
options.onMomentumScrollBegincallbackMomentum begin handler.
options.onMomentumScrollEndcallbackMomentum end handler.
options.ensureScrollableContentMinHeightbooleanExperimental min-height behavior.

Returns

PropertyTypeDescription
scrollableProps.onScrollhandlerManaged scroll handler to spread onto the scrollable.
scrollableProps.onLayouthandlerLayout handler for min-height calculations.
scrollableProps.refreshControlReactElement | undefinedResolved refresh control.
scrollableProps.refAnimatedRefAnimated ref for the scrollable.
headerMotionContext.originalHeaderHeightnumberHeader height for content offsetting.
headerMotionContext.contentContainerMinHeightnumber | undefinedComputed minimum content height.

Usage

import { useScrollManager } from 'react-native-header-motion';
import Animated from 'react-native-reanimated';

function CustomScrollable() {
const { scrollableProps, headerMotionContext } = useScrollManager('custom');

return (
<Animated.ScrollView {...scrollableProps}>
<View style={{ paddingTop: headerMotionContext.originalHeaderHeight }}>
{/* content */}
</View>
</Animated.ScrollView>
);
}

Must be called within a HeaderMotion subtree.