fix: add mobile swipe navigation to history lightbox#40
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces vertical swipe navigation to the ImageLightbox component. A new reusable hook ( Changes
Sequence DiagramsequenceDiagram
participant User as User/Touch Device
participant Hook as useVerticalSwipeNavigation
participant Lightbox as ImageLightbox
participant Shell as StudioShell
participant State as Gallery State
User->>Hook: Pointer Down (touch start)
Hook->>Hook: Initialize swipe tracking
User->>Hook: Pointer Move (drag)
Hook->>Hook: Calculate deltaX/deltaY & validate direction
Hook->>Hook: Enforce vertical lock if dominant
User->>Hook: Pointer Up (touch end)
Hook->>Hook: Validate swipe distance & dominance
Hook->>Lightbox: onSwipeUp/onSwipeDown callback
Lightbox->>Lightbox: Suppress backdrop click
Lightbox->>Shell: mediaNavigation.onNext/onPrevious()
Shell->>State: Update lightbox image index
Shell->>Shell: Re-render with new image
Shell->>Lightbox: Update mediaNavigation state
Lightbox->>Lightbox: Reset suppression on image change
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly Related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e895a162e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| onSwipeUp: mediaNavigation?.hasNext | ||
| ? () => { | ||
| suppressBackdropClickRef.current = true; | ||
| mediaNavigation.onNext(); | ||
| } |
There was a problem hiding this comment.
Suppress backdrop close for blocked swipe directions
The backdrop-click suppression is only set when hasNext/hasPrevious is true, so at the first or last gallery item a long swipe in the unavailable direction leaves suppressBackdropClickRef unset. In browsers that still emit a click after that touch sequence (the same behavior this ref is guarding against on successful swipes), handleBackdropCloseAttempt will treat it as a real backdrop click and close the lightbox instead of no-oping at the boundary.
Useful? React with 👍 / 👎.
Summary
Testing
Summary by CodeRabbit
New Features
Tests