fix(android): correct drag indicator resource column after scroll snap#18
Draft
sgandhi-gg wants to merge 1 commit into
Draft
Conversation
…lumn On Android the final onScroll event fires fractionally before the snap target settles, so Math.floor was resolving to the previous page index and placing the drag indicator in the wrong resource column. Switching to Math.round makes the fractional offset round to the nearest column, and an additional clamp(0, resourcePerPage-1) guards against any out-of-bounds index that could still slip through.
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.
Problem
On Android, when the user long-presses an event to initiate a drag, the drag indicator dot snaps to the wrong resource column.
This happens because Android's scroll view fires its final
onScrollevent fractionally before the snap animation finishes. At that pointoffsetX.valueis still a few pixels short of the snap target, soMath.floor(offsetX.value / resourceWidth)resolves to the previous page index — placing the indicator one column to the left.Fix
Two changes in
DragEventProvider.tsx(resource-scroll path, ~line 1222):Math.floor→Math.roundforfirstVisibleItemIndexRounding the fractional offset means it naturally snaps to the nearest column even when the final scroll event arrives slightly early.
Clamp
resourceVisualIndexto[0, resourcePerPage - 1]Guards against any residual out-of-bounds index that could slip through after the round (e.g. if the offset overshoots on a fast fling).
Files Changed
packages/react-native-calendar-kit/src/context/DragEventProvider.tsxTesting
Reproduce on an Android device with resource-scroll mode enabled:
Made with Cursor