Skip to content

fix(android): correct drag indicator resource column after scroll snap#18

Draft
sgandhi-gg wants to merge 1 commit into
fix/unavailable-hours-timezone-mismatchfrom
fix/android-drag-indicator-resource-column
Draft

fix(android): correct drag indicator resource column after scroll snap#18
sgandhi-gg wants to merge 1 commit into
fix/unavailable-hours-timezone-mismatchfrom
fix/android-drag-indicator-resource-column

Conversation

@sgandhi-gg

Copy link
Copy Markdown
Collaborator

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 onScroll event fractionally before the snap animation finishes. At that point offsetX.value is still a few pixels short of the snap target, so Math.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):

  1. Math.floorMath.round for firstVisibleItemIndex
    Rounding the fractional offset means it naturally snaps to the nearest column even when the final scroll event arrives slightly early.

  2. Clamp resourceVisualIndex to [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.tsx

Testing

Reproduce on an Android device with resource-scroll mode enabled:

  1. Long-press any event on the second or later resource column.
  2. Before the fix — indicator appears in the column to the left.
  3. After the fix — indicator appears in the correct column.

Made with Cursor

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant