-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: facebook header behaviour- hide header on scroll down, appear on scroll up #37
Comments
EDIT: one way to make this work is to handle onScrollWorklet to track the scroll direction and change the shared value opacity that we can pass to the Header component as showNavBar value (0 or 1) |
Hey there, I won't be able to work on this right now, but isn't this already possible with your approach if you use the absoluteHeader prop too? This is a little more involved than just doing that, because some features of the ScrollView break (e.g., sticky header indices) when this approach is used. Right now, you can do something like the following: interface HeaderComponentProps extends ScrollHeaderProps {
headerTranslationY: SharedValue<number>;
}
const HeaderComponent: React.FC<...> = ({ headerTranslationY }) => {
const animatedHeaderStyle = useAnimatedStyle(() => {
// Just translate the header upwards or downwards using the `transform` property using `headerTranslationY `
});
return (
<Animated.View style={animatedHeaderStyle}>
<Header ... />
</Animated.View>
)
} and the component is used like so: const Page = () => {
const headerTranslationY = useSharedValue(0);
return (
<ScrollViewWithHeaders
HeaderComponent={hcp => <HeaderComponent {...hcp} headerTranslationY={headerTranslationY} />}
absoluteHeader
onScrollWorklet={(event) => {
"worklet";
// Adjust the headerTranslationY based on the scroll's event value (use the translation values).
}}
/>
)
} This was all written in the PR editor so the code might not be accurate, but it is generally what you should do to achieve that. |
@e-younan thanks for the suggestion, i will also try this approach, for now what i did was just tracking scroll direction and passing the showNavBar opacity to the Header component: ``export const HeaderTest = () => { const onContentSizeChange = (width: number, height: number) => { const onLayout = (evt: LayoutChangeEvent) => { const scrollHandlerWorklet = (evt: NativeScrollEvent) => {
}; return ( |
Feature Request
Achieve hide header on scroll down and re-appear on scrolling up - Facebook behaviour
Use Case
Facebook header behaviour
Proposed Solution
Can the default behaviour be reverted?
Additional Information
Just look at the fb app
The text was updated successfully, but these errors were encountered: