Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat(carousel): add swipe deck with snap, indicators, and parallax #432
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?
Uh oh!
There was an error while loading. Please reload this page.
feat(carousel): add swipe deck with snap, indicators, and parallax #432
Changes from all commits
0e8e5edd8821daFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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.
dragState.current.movedis set but never read.Line 256 tracks whether the pointer moved past a 3px threshold, but neither
onPointerUpnoronPointerCancelconsult it. Consequently, a plain mouse click anywhere in the deck always triggers a smoothscrollToIndex(nearestIndex(...))on release, which can produce an unexpected micro-scroll even when the user didn't intend to drag. Either use the flag to suppress the snap on pure clicks, or drop it to remove dead state.♻️ Proposed fix
onPointerUp={(event) => { const container = deckRef.current; if (!container || dragState.current.pointerId !== event.pointerId) { return; } container.releasePointerCapture(event.pointerId); setIsDragging(false); - scrollToIndex(nearestIndex(container)); + if (dragState.current.moved) { + scrollToIndex(nearestIndex(container)); + } + dragState.current.pointerId = -1; }} onPointerCancel={(event) => { const container = deckRef.current; if (!container || dragState.current.pointerId !== event.pointerId) { return; } container.releasePointerCapture(event.pointerId); setIsDragging(false); - scrollToIndex(nearestIndex(container)); + if (dragState.current.moved) { + scrollToIndex(nearestIndex(container)); + } + dragState.current.pointerId = -1; }}📝 Committable suggestion
🤖 Prompt for AI Agents
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.
Expose active indicator to assistive tech with
aria-current.The dot buttons only differ visually for the active card (width + color). Screen reader users get no indication which card is current. Adding
aria-currentmakes the active state announceable.♿ Proposed fix
{items.map((item, index) => ( <button key={item.id} type="button" onClick={() => scrollToIndex(index)} aria-label={`Go to card ${index + 1}`} + aria-current={activeIndex === index ? "true" : undefined} className={cn( "h-2.5 rounded-full transition-all duration-300", activeIndex === index ? "w-8 bg-teal-600" : "w-2.5 bg-stone-300 hover:bg-stone-400", )} /> ))}📝 Committable suggestion
🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.