快速滑动可跳过多张幻灯片返回下一张幻灯片(embla-carousel)

问题描述 投票:0回答:1

当每个视图使用多个滑块时,我在轮播组件中遇到意外行为。当我调整基础属性以实现每个滑块宽度为 33.3333% 的布局,并尝试快速滑动以跳过多张幻灯片(例如,从幻灯片 1 到幻灯片 4)时,轮播会弹回到幻灯片 2。

swiper 和 embla 之间的比较:https://vimeo.com/937262995?share=copy

codesandbox 链接:https://codesandbox.io/p/sandbox/carousel-wmzl49

shadcnui embla-carousel
1个回答
0
投票

这是默认行为。将 skipSnaps 选项设置为 true,然后就可以开始了。以下是使用 Shadcn UI 将选项传递到 Embla Carousel 的如何

<Carousel
  opts={{
    skipSnaps: true
  }}
>
 …
</Carousel>
© www.soinside.com 2019 - 2024. All rights reserved.