react-native - 无限循环无法使用 loop={true} , enableSnap ={true} 列表未在 android 中使用 react-native-snap-carousel 滚动无限模式
问题描述
实际行为
我在卡片中显示列表并且卡片没有在无限模式下滚动它在android中间被击中
预期行为
在android中滚动时,卡片应该在无限模式下滚动
<Carousel
ref={c => {
this._carousel = c;
}}
carouselRef={this.props._slider1Ref}
data={this.props.data}
renderItem={this._renderItem}
sliderWidth={this.props.sliderWidth}
itemWidth={this.props.itemWidth}
loop={true}
loopClonesPerSide={this.props.loopClonesPerSide}
firstItem={this.props.firstItem}
onSnapToItem={index => this.onSnap(index)}
layout={this.props.layout}
layoutCardOffset={this.props.layoutCardOffset}
showSpinner={this.props.showSpinner}
activeSlideAlignment="start"
useScrollView={false}
activeSlideOffset={this.props.activeSlideOffset}
lockScrollWhileSnapping={true}
enableSnap={true}
enableMomentum={false}
activeSlideOffset={this.props.activeSlideOffset}
decelerationRate="fast"
// removeClippedSubviews={true}
removeClippedSubviews={false}
/>
解决方案
转到 node_modules/react-native-snap-carousel/src/carousel/Carousel.js 并编辑第 820 行
if (nextActiveItem === this._itemToSnapTo && scrollOffset === this._scrollOffsetRef) {
this._repositionScroll(nextActiveItem);
}
至
if (nextActiveItem === this._itemToSnapTo && Math.trunc(scrollOffset) === Math.trunc(this._scrollOffsetRef)) {
this._repositionScroll(nextActiveItem);
}
推荐阅读
- mysql - 将sql查询组合在一起
- javascript - 控制 DOM 中的每个“src”属性更改
- javascript - 未捕获的 ReferenceError: sel 未在 HTMLDivElement.onclick 中定义
- html - 如果元素定位已经受到容器 div 的影响,如何在 CSS 中创建下拉菜单?
- android - 当应用程序因来电事件关闭时,如何发送通知?
- c# - 如何根据对象的出现改变边框的样式?
- powershell - 为什么这两个 PowerShell 脚本的“调用命令”运行时间如此不同
- google-apps-marketplace - 谷歌市场应用程序安装后如何自定义成功屏幕?
- twig - 如果其他在 opencart 3 树枝文件中不起作用
- azure - VS Code Azure 帐户扩展要求选择订阅