Repository navigation
[Help]: Lock-in Slide after drag free swiping #963
SummaryHello, I want to "lock-in" a slide after swiping with drag free option enabled in order to display the current slide and not to "hang" between two slides. I have this code which works pretty well besides a delay before calling the event. I know this is expected behaviour as the documentation says: "Please note that this can take longer than you think when dragFree is enabled" But what can I do to achieve the behavior I descriped without a delay? Is there another approach for dragFree + lock-in? embla?.on("settle", () => {
embla.scrollTo(embla.selectedScrollSnap(), true);
});`If applicable, which variants of Embla Carousel are relevant to this question?
Additional informationNo response CodeSandbox exampleNo response |
Answered by
davidjerleke
Aug 3, 2024
Replies: 1 comment 3 replies
|
@VMLuca I don’t have access to my computer for a day or two, but this could possibly work: emblaApi.on('pointerUp', (emblaApi) => {
const { scrollTo, target, location } = emblaApi.internalEngine()
const diffToTarget = target.get() - location.get()
scrollTo.distance(diffToTarget, true)
}) |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@VMLuca there is an option called skipSnaps. If you set that to
truethe carousel will skip snaps if dragged in a vigorous manner.