Skip to content

fix: reset drag state on pointer leave to prevent stuck transitions#113

Open
q404365631 wants to merge 1 commit intowethegit:mainfrom
q404365631:fix-gallery-drag-leave
Open

fix: reset drag state on pointer leave to prevent stuck transitions#113
q404365631 wants to merge 1 commit intowethegit:mainfrom
q404365631:fix-gallery-drag-leave

Conversation

@q404365631
Copy link
Copy Markdown

Problem

When the draggable prop is set to true and the pointer leaves the gallery area during a drag/swipe, the gallery gets stuck in an in-between state because the drag flags are never reset.

Solution

Add an onPointerLeave handler to GalleryMain that mirrors the onPointerUp logic:

  • Checks the current xOffset against swipeThreshold
  • Transitions to the next/previous item if the threshold is exceeded
  • Resets all touch state (isDragging, xOffset, start, offsetting, scrolling)

Changes

  • Added handlePointerLeave callback in gallery-main.jsx
  • Wired it to the ul element onPointerLeave event

Closes #112

When the draggable prop is enabled and the pointer leaves the gallery area
during a drag, the gallery previously remained in an in-between state because
isDragging was never reset. This adds an onPointerLeave handler that mirrors
the onPointerUp logic: it checks the swipe threshold and transitions to the
nearest item, then resets all touch state.

Closes wethegit#112
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.

Gallery gets stuck mid-transition when swiping/dragging

1 participant