We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.1.5]
[1.1.4]
下面展示的是一个包括下拉刷新,上拉加载更多的高性能瀑布流列表
截屏
截图gif
v1.1.5
npm install react-native-waterfall-flow --save
import WaterfallFlow from 'react-native-waterfall-flow'
<WaterfallFlow data={data} numColumns={2} renderItem={({ item, index, columnIndex }) => { return ( <View> <Text>index: {index}</Text> <Text>columnIndex: {columnIndex}</Text> <View/> ) }} ... />
几乎所有FlatList的属性都是支持的,这里只列出一些常用的属性,其余属性可查看FlatList文档
renderItem
function
item
index
columnIndex
示例用法:
<WaterfallFlow renderItem={({ item, index, columnIndex }) => { return ( <View> <Text>index: {index}</Text> <Text>columnIndex: {columnIndex}</Text> <View/> ) }} ... />
如何设置间距
renderItem方法暴露出了columnIndex,该属性表示当前item在列表中第几列,这样你就能够自由的控制每个item的上下左右间距了。item的宽度等于 瀑布流容器的宽度 / numColumns
瀑布流容器的宽度
numColumns
<WaterfallFlow renderItem = {({ item, index, columnIndex }) => { return ( <View style={{ paddingLeft: columnIndex === 0 ? 12 : 6, paddingRight: columnIndex === 0 ? 6 : 12, paddingTop: 3, paddingBottom: 3 }} > <View/> ) }} ... />
data
array
number
ListHeaderComponent
component
<WaterfallFlow ListHeaderComponent = { <View> <Text>this is header<Text> <View/> } ... />
ListFooterComponent
<WaterfallFlow ListFooterComponent = { <View> <Text>this is footer<Text> <View/> } ... />
ListEmptyComponent
<WaterfallFlow ListEmptyComponent = { <View> <Text>no data here<Text> <View/> } ... />
onEndReached
(info: {distanceFromEnd: number}) => void
onRefresh
() => void
RefreshControl
refreshing
boolean
style
view styles
{ flex: 1 }
contentContainerStyle
建议将其用于设置容器背景色。 示例:
<WaterfallFlow contentContainerStyle={{ backgroundColor: '#f9f9f9' }} ... />
所有和方法和FlatList保持一致,这里只列出几个常用的,其余方法可查看FlatList文档
scrollToEnd()
scrollToEnd([params])
滚动到瀑布流列表的底部
object
params的参数如下:
true
方法调用示例
绑定ref:
<WaterfallFlow ref={ref => this.listRef = ref} ... />
调用方法:
this.listRef.scrollToEnd()
scrollToIndex()
scrollToIndex([params])
将位于指定位置的元素滚动到可视区的指定位置,当viewPosition 为 0 时将它滚动到屏幕顶部,为 1 时将它滚动到屏幕底部,为 0.5 时将它滚动到屏幕中央。
scrollToOffset()
scrollToOffset([params])
滚动列表到指定的偏移(以像素为单位),等同于ScrollView的scrollTo方法。
示例代码 是一个expo app, 像这样启动项目
cd examples npm i npm start
react-native-waterfall-flow is MIT licensed, as found in the LICENSE file.
react-native-waterfall-flow
The text was updated successfully, but these errors were encountered:
No branches or pull requests
react-native-waterfall-flow
React Native 高性能瀑布流组件
特性
Changelogs
[1.1.5]
[1.1.4]
展示案例
截屏
截图gif
安装
基本使用
属性
renderItem
function
item
渲染到列表中item
(Object): 当前项的数据index
(number): 当前项的索引columnIndex
(number): 当前项在列表中的第几列示例用法:
如何设置间距
renderItem
方法暴露出了columnIndex
,该属性表示当前item
在列表中第几列,这样你就能够自由的控制每个item的上下左右间距了。item的宽度等于瀑布流容器的宽度
/numColumns
示例用法:
data
array
numColumns
number
ListHeaderComponent
component
,function
示例用法:
ListFooterComponent
component
,function
示例用法:
ListEmptyComponent
component
,function
示例用法:
onEndReached
function
onRefresh
function
RefreshControl
控件,以便实现“下拉刷新”的功能。同时你需要正确设置refreshing
属性。refreshing
boolean
style
view styles
{ flex: 1 }
的样式,即高度充满父容器contentContainerStyle
view styles
建议将其用于设置容器背景色。 示例:
方法
scrollToEnd()
滚动到瀑布流列表的底部
参数:
object
params的参数如下:
true
.方法调用示例
绑定ref:
调用方法:
scrollToIndex()
将位于指定位置的元素滚动到可视区的指定位置,当viewPosition 为 0 时将它滚动到屏幕顶部,为 1 时将它滚动到屏幕底部,为 0.5 时将它滚动到屏幕中央。
参数:
object
params的参数如下:
true
scrollToOffset()
滚动列表到指定的偏移(以像素为单位),等同于ScrollView的scrollTo方法。
参数:
object
params的参数如下:
true
示例
示例代码 是一个expo app, 像这样启动项目
cd examples npm i npm start
License
react-native-waterfall-flow
is MIT licensed, as found in the LICENSE file.The text was updated successfully, but these errors were encountered: