Skip to content

fix: gallery item getting stuck #114

Open
saugatmalla wants to merge 3 commits intomainfrom
fix/gallery-item-stuck
Open

fix: gallery item getting stuck #114
saugatmalla wants to merge 3 commits intomainfrom
fix/gallery-item-stuck

Conversation

@saugatmalla
Copy link
Copy Markdown

Description

This fixes the issue in touch devices, when the drag is cancelled by browser's scroll pan-y and the gallery item gets stuck in weird position.
We are adding pointercancel event to reset the gallery item.

To reproduce, use touch devices and drag the gallery diagonally. It is a little tricky to reproduce.

Attached before and after screen recording - notice that gallery item resets in the After.
Before:

before.mov

After:

after.mov

This fixes #112.

@saugatmalla saugatmalla requested a review from andrewrubin May 5, 2026 23:14
Comment thread package.json
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming changeset is working correctly, we can revert this to 4.0.0 for this PR

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, weird. Not sure how this changed to lower version. I don't remember manually changing package version to this.

Copy link
Copy Markdown
Member

@andrewrubin andrewrubin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @saugatmalla! I'm not sure we're on the same page with the issue that #112 describes. Maybe it's my mistake, and I wasn't clear with what I was seeing with Sean.

It happens with any device, not even touch screen, where if you start a drag inside the gallery and then move it out, the drag doesn't cancel, see attached. If you think this is an entirely different issue, we can track these two things separately

Screen.Recording.2026-05-06.at.17.20.42.mp4

@saugatmalla
Copy link
Copy Markdown
Author

saugatmalla commented May 7, 2026

It happens with any device, not even touch screen

It looks like these two are separate, I may have mistaken this issue and Sean's issue. This issue seems like we are losing drag outside of the gallery on pointer devices and selecting text. But, lets keep both of the scope in this PR.

So, if the pointer was down on gallery and dragging, it should still drag even the pointer moves outside, and snap to the correct position on pointerup anywhere.
We could do similar to the Page Flip using .setPointerCapture() and adding pointerId

@andrewrubin

@andrewrubin
Copy link
Copy Markdown
Member

Agreed, pointerCapture sounds like a great plan @saugatmalla !

@saugatmalla
Copy link
Copy Markdown
Author

@andrewrubin I have updated to use setPointerCapture, so the pointer is not lost outside of the gallery. Also, refactored handlePointerCancel method slightly from my previous commits.

@saugatmalla saugatmalla requested a review from andrewrubin May 7, 2026 23:57
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

2 participants