Gathering detailed insights and metrics for react-native-refresh-view-pure
Gathering detailed insights and metrics for react-native-refresh-view-pure
npm install react-native-refresh-view-pure
Typescript
Module System
Node Version
NPM Version
73.5
Supply Chain
98.9
Quality
75
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
599
Last Day
1
Last Week
1
Last Month
6
Last Year
54
7 Stars
21 Commits
3 Forks
3 Watching
2 Branches
1 Contributors
Latest Version
1.1.5
Package Id
react-native-refresh-view-pure@1.1.5
Size
30.77 kB
NPM Version
5.3.0
Node Version
8.2.1
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-50%
1
Compared to previous week
Last month
20%
6
Compared to previous month
Last year
-6.9%
54
Compared to previous year
No dependencies detected.
react-native纯js编写的上下拉刷新组件。
如果想要使用自定义的gif图片,则需要自己编写ImageManager.js文件,绑定自己的图片。
react-native ,pure JS code for refresh and load more. ps: if you want to use your own images, you must edit ImageManager.js ,make sure it can load your images in a right way.
import {JBRefreshView,JBRefreshConfig} from './JBRefreshView'
JBRefreshConfig可选,用来配置一些全局属性,默认来说,上下拉刷新组件都是统一制定好的,所以在启动时设定为自己想要的全局配置即可,对于需要根据情况特殊配置的,则使用JBRefreshView提供的属性进行配置。
直接使用JBRefreshView替换scrollView,增加上下拉刷新能力。
//最简单的使用例子
onRefresh=(PullRefresh)=> {
//do something
setTimeout(() => {
this.refs['KEY_REFRESH'].refreshed();
}, 3000);
}
<View style={[styles.container]}>
<JBRefreshView
ref={'KEY_REFRESH'}
onRefresh={this.onRefresh}
useLoadMore={false}
>
<View style={{ backgroundColor: '#eeeeee' }}>
<Text>9</Text>
<Text>13</Text>
<Text>14</Text>
</View>
</JBRefreshView>
</View>
重写listview的内部scrollview用JBRefreshView替代,或者外面直接套用JBRefreshView都可以。 以下提供两种方法实例,如无特殊情况,推荐使用外层套用JBRefreshView,并给JBRefreshView设定refs来使用其中的refreshed等方法。
//直接套路的例子
onRefresh = () => {
var self = this;
setTimeout(function () {
self.setState({
dataSource: self.state.dataSource.cloneWithRows(['我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell'])
});
this.refs[KEY_REFRESH].refreshed();
//PullRefresh.refreshed();
}, 5000);
}
onLoadmore = () => {
var self = this;
setTimeout(function () {
self.data = self.data.concat(['我是一个cell(新)']);
self.setState({
dataSource: self.state.dataSource.cloneWithRows(self.data)
});
this.refs[KEY_REFRESH].loaded();
//PullRefresh.loaded();
//没有数据了,没有加载更多,则useLoadMore赋值为false
}, 5000);
}
render() {
return (
<RefreshView
ref={KEY_REFRESH}
onRefresh={this.onRefresh}
onLoadmore={this.onLoadmore}
useLoadMore={this.state.loadmore}
>
<ListView
style={{ flex: 1 }}
dataSource={this.state.dataSource}
renderRow={this._renderRow}
/>
</RefreshView>
)}
//重写renderScrollComponent的例子
onRefresh(PullRefresh) {
var self = this;
setTimeout(function () {
self.setState({
dataSource:self.state.dataSource.cloneWithRows(['我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell', '我是一个cell'])
});
PullRefresh.refreshed();
}, 5000);
}
onLoadmore(PullRefresh) {
var self = this;
setTimeout(function () {
self.data = self.data.concat(['我是一个cell(新)']);
self.setState({
dataSource: self.state.dataSource.cloneWithRows(self.data)
});
PullRefresh.loaded();
//没有数据了,没有加载更多,则useLoadMore赋值为false
}, 5000);
}
render() {
return (
<View style={styles.container}>
<ListView
renderScrollComponent={(props) =>
<JBRefreshView
onRefresh={(PullRefresh) => this.onRefresh(PullRefresh)}
onLoadmore={(PullRefresh) => this.onLoadmore(PullRefresh)}
useLoadMore={true}
/>}
dataSource={this.state.dataSource}
renderSeparator={(sectionID, rowID) => <View key={`${sectionID}-${rowID}`} style={styles.separator} />}
renderRow={(rowData) => <View style={styles.rowItem}><Text style={{ fontSize: 16 }}>{rowData}</Text></View>}
/>
</View>
)}
//告知外部,当前刷新状态的方法
onStatusChange: PropTypes.func,
//下拉刷新函数
onRefresh: PropTypes.func,
//上拉加载更多函数
onLoadmore: PropTypes.func,
//是否有loadmore
useLoadMore:PropTypes.bool,
//上下拉自定义的高度,全局设定建议在JBRefreshConfig设定好
topIndicatorHeight: config.topHeight,
bottomIndicatorHeight: config.bottomHeight,
//恢复默认位置的动画时间
duration: 300,
//当前模式选择字段
refreshType: 'normal',
//是否有loadmore功能
useLoadMore: false,
//自定义上下拉显示的view
customView: null,
customBottomView: null,
refreshed () //刷新完成后调用
loaded () //加载更多完成后调用
所以,我第一版上下拉刷新按照iOS原生方式去实现,测试时发现在安卓上不能跑,导致浪费了时间和精力。
总结如下: 详见:
http://blog.csdn.net/zramals/article/details/78403508
有任何问题请留言,
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/18 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More