Feature: Expose isDragging state via Context#493
Open
romulosalmeida wants to merge 1 commit intoPedroBern:mainfrom
Open
Feature: Expose isDragging state via Context#493romulosalmeida wants to merge 1 commit intoPedroBern:mainfrom
romulosalmeida wants to merge 1 commit intoPedroBern:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, there's no way for external components to know when the user is actively dragging a scrollable tab. This limits the ability to coordinate animations and gestures between custom animation (headers in my case) and the scroll content.
What's New
Added a new isDragging shared value to the Context, allowing any component within Tabs.Container to reactively track the drag state of the focused tab.
Changes
Container.tsx:
Added isDragging shared value initialization
Exposed isDragging in the Context Provider
hooks.tsx:
Added isDragging to useTabsContext() destructuring in useScrollHandlerY
Added setDragging helper function
Update isDragging to true on onBeginDrag
Update isDragging to false on onEndDrag
types.ts
Added isDragging: Animated.SharedValue to ContextType
Use Case
This feature enables developers to react to drag state changes from any component within the Tabs context. Example use cases:
Cancel header animations on drag: When implementing custom scrollable headers with momentum/decay animations, cancel them when the user starts dragging the scroll view to avoid conflicts
UI feedback: Show visual indicators during active scrolling
Gesture coordination: Prevent or allow gestures based on scroll drag state
Example:
Testing