Header behavior - Help
This isn't really an issue, but more an help request.
I am trying to use the library in my project, however I was wondering if and how I could support / add a different behavior to hide and show the title.
Basically what I would like is when the user is scrolling down (swiping up) hide the title an keep tabs sticky, when the user is scrolling up (scrolling treshold??) showing again the title even if the offset of the current scrollable content did not reach 0. More or less the behavior that we see on the navigationBar when hidesBarsOnSwipe is set.
Do you think this will be possible, if yes could you point me in the right direction? I'm willing to make the modification myself in a fork.
Thanks in advance for your help and for open sourcing this library
Looking into this. I think I understand, but just to confirm:
- When scrolling down, the header shrinks the way it does currently by following the scroll one-to-one
- When scrolling up by some threshold, the header expands back to full size immediately
Is that right?
Closing this. Reopen if and when you're ready to resume the discussion
Sorry, but somehow I did not get a notification when you replied. However you got it right
I have an initial implementation on the branch work/snap if you'd like to take a look and give me your input. Right now, it only works with StickyHeader. For MaterialTabs, I still need to do some work to maintain proper state when switching between tabs.
https://github.com/user-attachments/assets/ee87c07c-8fef-40b7-9c52-498d2789e58b
To be clear, you can test it in your app with tabs, but there might be some glitchy behavior when switching between tabs. From the change log:
2.0.7
Improvements
- Implement #21 - Add scroll-up snap behavior for sticky headers. When enabled, the header automatically snaps to fully expanded state after detecting scroll-up intent, making it easier to reveal collapsed headers without extensive scrolling.
// Enable snap-to-expanded behavior
MaterialTabs(
config: MaterialTabsConfig(
headerConfig: HeaderConfig(scrollUpSnapMode: .snapToExpanded)
)
) { }
// Or for StickyHeader
StickyHeader(
config: HeaderConfig(scrollUpSnapMode: .snapToExpanded)
) { }
@wtmoose I will try it later today, an I will let you know. Anyway thank you for having spent time on this one
@oiledCode are you still interested in this feature?
@wtmoose I'm interested in the feature! I think it makes sense to have the ability to snap headers in place without having to scroll so much.