Closed matthewwo closed 3 years ago
Thanks @prankymat for adding this feature.
I recommend moving the pagingEnabled ternary logic outside of the JSX for maintainability's sake. While it's convenient to place it inline, it's not as clear what the intent is.
thanks @peacechen for the advice! moved the ternary outside of JSX, is this better, or should we get rid of the ternary completely like this?
let scrollViewProps = {
showsHorizontalScrollIndicator: false,
contentContainerStyle: {paddingRight: this.state.itemWidth / 2}
}
if (this.props.pagingEnabled) {
Object.assign(scrollViewProps, {
decelerationRate: 0,
snapToInterval: this.state.itemWidth * this.state.numVisibleItems
})
}
Thanks @prankymat Your change is good. What do you think about a clearer demarcation between the base scrollViewProps and the paging props like this:
const pagingProps = this.props.pagingEnabled ? {
decelerationRate: 0,
snapToInterval: this.state.itemWidth * this.state.numVisibleItems
} : {};
return (
<View
style={{ height: this.state.itemHeight, flex: 1 }}
onLayout={this.onLayout}
>
<RecyclerListView
ref={rlv => this.rlv = rlv}
layoutProvider={this.state.layoutProvider}
dataProvider={this.state.dataProvider}
rowRenderer={this.rowRenderer}
extendedState={this.props.renderDayParams}
initialRenderIndex={this.props.initialRenderIndex}
onVisibleIndicesChanged={this.onVisibleIndicesChanged}
isHorizontal
externalScrollView={this.props.externalScrollView}
scrollViewProps={
showsHorizontalScrollIndicator: false,
contentContainerStyle: {paddingRight: this.state.itemWidth / 2},
...pagingProps
}
/>
</View>
Either way is ok. To me that is clearer at a glance which are the boilerplate scrollView props and which are for paging.
totally agree with you, will push a change!
Thanks @prankymat This will be included in the next release
Addressing #215.
scrollerPaging
will only work ifscrollable
is also set totrue
.