-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add swipe gesture support with carousel-style transitions for image viewer navigation #8703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
lstein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot, could you add some animation so that during the swipe transition from one image to the next you see the next image "pushing" the previous image out of the way? This means that transiently portions of both images will be visible.
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Added in commit f4a964a. During swipe, the adjacent image now appears positioned outside the viewport and slides into view as you drag, creating the "pushing" effect. Both images are visible simultaneously during the transition. How it works:
The previous/next images are positioned at |
lstein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The animated images should go all the way across the viewport, similar to what is provided by the Swiper (swiperjs.com) library:
- At the start of the animation
| |
| image 1 |
| |
- Halfway through the animation:
| | | |
|mage 2 | | imag|
| | | |
- Animation complete:
| |
| image 2 |
| |
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Updated in commit e4e11e5. The swipe animation now uses a full-width carousel layout similar to Swiper.js:
The transition now shows each image spanning the complete viewport as they slide horizontally, matching the behavior described in your diagrams. |
|
@copilot I do not see the carousel-style transitions at all. Instead, the current image jogs a little bit to the left or right (in the direction of the swipe), and then it is replaced by the next image. There is no sense of carousel movement. |
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Fixed in commit b2d0f58. The issue was that Changes made:
The carousel should now move smoothly across the full viewport, with all three images (previous, current, next) sliding together as you drag. |
|
@copilot This is now very close. Just put an upper cap on the speed of the animation. When the user flicks their finger rapidly across the image, the transition is almost instantaneous, which spoils the effect. The transition from one slide to the next should take at least 300 ms. It would be good to define a constant that limits the speed, and then I can experiment with different settings to find the one I prefer. |
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Implemented in commit e01bb90. Added Changes:
You can now adjust the |
|
@copilot There has now been a regression:
|
…sn't occur Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Fixed in commit 37d92e5. The retrograde motion was caused by the snap-back animation occurring even when navigation was triggered. Changes:
The carousel now smoothly transitions: drag → release → next image appears centered (if threshold exceeded) or smooth snap back to current image (if threshold not exceeded). |
|
@copilot Almost perfect. Last thing to do is to disable the animation when the leftmost image is selected and the user swipes to the right, and disable the animation when the rightmost image is selected and the user swipes to the left. (In other words, don't try to advance beyond the ends of the image list) |
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Implemented in commit b4c6c5a. Added boundary constraints to prevent dragging beyond the image list edges. Changes:
Users can no longer swipe beyond the boundaries of the image list. |
Summary
Enables horizontal swipe gestures in the image viewer to navigate between images on touch devices like iPads. Swipe left for next image, right for previous. Uses framer-motion's drag API with a 50px threshold to prevent accidental triggers.
During the swipe transition, images are displayed in a full-width carousel layout similar to Swiper.js, where each image spans the entire viewport and slides horizontally across the screen. The carousel container holds three image slots (previous, current, next) with smooth animated transitions as you drag.
Changes:
useSwipeNavigation.ts- Encapsulates swipe logic, mirrors existing arrow button navigation, provides adjacent image names and boundary flagsCurrentImagePreview.tsx- Implements 300% width carousel container with three full-width image slots for previous, current, and next imagesleft: -100%to center current image in viewportMIN_TRANSITION_DURATIONconstant (300ms) to prevent instant transitions when users flick rapidly, ensuring smooth and controlled animationsRelated Issues / Discussions
Addresses enhancement request for touch-friendly navigation on tablets.
QA Instructions
Desktop Testing:
Touch Device Testing:
Configuration Testing:
MIN_TRANSITION_DURATIONconstant can be adjusted inCurrentImagePreview.tsxto experiment with different transition speedsMerge Plan
No special considerations. No schema changes, no breaking changes.
Checklist
What's Newcopy (if doing a release after this PR)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.