在Android中水平滚动的手动滚动的问题
我正在使用反应 - 塞子赛车来显示横幅。在iOS中,对于手动滚动以及间隔后的自动滚动都可以正常工作,但是在手动滚动时,它在Android时遇到了两个问题。
- 对于某些设备,特别是三星,它被卡在第三个索引上(手动完成时,但自动工作正在工作)。
- 对于所有设备,在手动滚动时显示横幅似乎有一个滞后。测试了各种设备。
我使用了以下代码。
<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.
- For some devices, specifically Samsung that it gets stuck at third index (When done manually, but automatic one is working).
- 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论