在Android中水平滚动的手动滚动的问题

发布于 2025-02-08 21:44:43 字数 1089 浏览 1 评论 0原文

我正在使用反应 - 塞子赛车来显示横幅。在iOS中,对于手动滚动以及间隔后的自动滚动都可以正常工作,但是在手动滚动时,它在Android时遇到了两个问题。

  1. 对于某些设备,特别是三星,它被卡在第三个索引上(手动完成时,但自动工作正在工作)。
  2. 对于所有设备,在手动滚动时显示横幅似乎有一个滞后。测试了各种设备。

我使用了以下代码。

 <Carousel
    onSnapToItem={(slideIndex: number) => {
      setSlideIndex(slideIndex);
    }}
    data={data}
    renderItem={renderSliderItem}
    sliderWidth={carouselWidth}
    itemWidth={carouselWidth}
    loop={true}
    slideStyle={{ width: carouselWidth }}
    autoplay={autoPlay}
    autoplayDelay={scrollInterval}
    autoplayInterval={scrollInterval}
    useScrollView
    enableSnap={true}
    shouldOptimizeUpdates={true}
    loopClonesPerSide={5}
    enableMomentum={true}
    activeSlideAlignment="center"
    removeClippedSubviews={true}
    decelerationRate={0.9}
    inactiveSlideScale={1}
    inactiveSlideOpacity={1}
    lockScrollWhileSnapping={true}
  />

在大多数情况下,减速性= {0.9},intactivesLideOpacity = {1}和enableMomentum = {true}似乎可以解决问题,但对我的情况不起作用。但是,当我设置pagingEnabled = {true}时,它似乎正在工作,但是自动滚动索引和手动滚动索引不同步。

从长久开始卡住。

I am using react-native-snap-carousel for showing the banners. It is working fine in iOS for both manual scroll as well as autoscroll after interval, but in android while scrolling it manually, facing two issues.

  1. For some devices, specifically Samsung that it gets stuck at third index (When done manually, but automatic one is working).
  2. For all devices, there seems to be a lag on showing the banner while scrolling manually. Tested for various devices.

I have used following code.

 <Carousel
    onSnapToItem={(slideIndex: number) => {
      setSlideIndex(slideIndex);
    }}
    data={data}
    renderItem={renderSliderItem}
    sliderWidth={carouselWidth}
    itemWidth={carouselWidth}
    loop={true}
    slideStyle={{ width: carouselWidth }}
    autoplay={autoPlay}
    autoplayDelay={scrollInterval}
    autoplayInterval={scrollInterval}
    useScrollView
    enableSnap={true}
    shouldOptimizeUpdates={true}
    loopClonesPerSide={5}
    enableMomentum={true}
    activeSlideAlignment="center"
    removeClippedSubviews={true}
    decelerationRate={0.9}
    inactiveSlideScale={1}
    inactiveSlideOpacity={1}
    lockScrollWhileSnapping={true}
  />

For most of the cases, decelerationRate={0.9},inactiveSlideOpacity={1} and enableMomentum={true} seems to fix the issue, but it is not working for my case. But when i set pagingEnabled={true}, it seems to be working but then the automatic scroll index and manual scroll index are not in sync.

Stuck since long.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文