[Feat]: Make drag snap threshold configurable #1353
Unanswered
suateneskoc
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Which variants of Embla Carousel are relevant to this feature request?
Feature description
I’d like Embla Carousel to expose an option for configuring how far a drag gesture must move toward an adjacent snap point before Embla commits to that snap on release.
Something like:
or maybe
The value could represent the fraction of distance toward the adjacent snap required before Embla scrolls to that snap on release. This would preserve regular snap behavior while making the carousel feel less resistant for gentle gestures.
My use case is a full-width snapping carousel where each slide takes the full viewport width. With trackpad horizontal scrolling, a gentle two-finger gesture can visibly move the carousel toward the next slide, but on release it often snaps back to the original slide. Users then have to repeat the gesture or scroll more forcefully.
I looked at the existing options, but none seem to control this specific behavior:
dragFreereduces resistance, but changes the carousel into free-drag/momentum behavior.dragThresholdsounds related, but appears to affect click handling rather than the snap commit threshold.skipSnapshandles vigorous drags skipping snap points, but does not make gentle adjacent-slide gestures commit sooner.durationaffects API-triggered scrolling, not drag interaction force/threshold.What I’m looking for is a way to keep dragFree: false and normal snapping, while lowering the threshold required to move to the next or previous snap.
Additional Context
My setup is React with full-width slides and trackpad support via
WheelGesturesPlugin({ forceWheelAxis: 'x' }).As a workaround, I listened to
pointerDownandpointerUp, stored the startingselectedScrollSnap()andscrollProgress(), then calledscrollTo()manually if the gesture moved more than 8% toward the adjacent snap.That works for my case, but it would be cleaner and more consistent if this threshold were configurable in Embla itself.
I found some related prior work while researching this:
dragThreshold, which seems related by name, but the currentdragThresholdoption appears to affect click handling rather than the snap commit threshold.dragThresholdoption #469 added the currentdragThresholdoption, but I don’t think it covers this specific “commit to next snap on release” behavior.I also noticed in the installed package source that the next-slide threshold appears to be internal/hard-coded:
Beta Was this translation helpful? Give feedback.
All reactions