npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-mjrefresh-xys

v0.7.4

Published

>React-Native-MJRefresh可完成使用React Native对IOS进行自定义下拉刷新设置 > >onPulling参数为{nativeEvent:percent},结合lottie-react-native可以获得绝佳的下拉刷新效果 > >自定义详情可见Example:[HuaWeiRefreshControl.js](https://github.com/react-native-studio/react-native-MJRefresh/blob/master/Examp

Downloads

19

Readme

React Native MJRefreshnpm version

React-Native-MJRefresh可完成使用React Native对IOS进行自定义下拉刷新设置

onPulling参数为{nativeEvent:percent},结合lottie-react-native可以获得绝佳的下拉刷新效果

自定义详情可见Example:HuaWeiRefreshControl.js

ListView使用见:ListViewExample

FlatList使用见:FlatListExample

Android自定义下拉刷新组件见React-Native-SmartRefreshLayout

安装

第一步

工程目录下运行:

npm install --save react-native-mjrefresh-xys (rn>=0.55.0)

npm install --save react-native-mjrefresh-lower (rn<=0.54)

or(已经安装了yarn)

 yarn add react-native-mjrefresh-xys (rn>=0.55)

 yarn add react-native-mjrefresh-lower (rn<=0.54)

Notice

| react-native | react-native-mjrefresh | |------------------|--------------| |<0.55 |使用react-native-mjrefresh-lower| | >=0.55 | * | | >=0.58 | 0.7.0 |

第二步

使用link添加:

工程目录下运行:

react-native link react-native-mjrefresh-xys (rn>=0.55)

react-native link react-native-mjrefresh-lower(rn<=0.54)

使用CocoaPods添加:

podfile添加:

  pod 'RCTMJRefreshHeader', :path => '../node_modules/react-native-mjrefresh'

执行:

  pod install

第三部使用

在工程中导入:

import MJRefresh,{ScrollView} from 'react-native-mjrefresh-xys'//rn>=0.55
//import MJRefresh,{ScrollView} from 'react-native-mjrefresh-lower'//rn<=0.54

//该ScrollView兼容官方所有的属性和方法,refreshControl也可以使用官方的RefreshControl
  state={
        text:'下拉刷新'
    }
  render() {
    return (
        <ScrollView
            refreshControl={
              <MJRefresh
                  ref={ref=>this._mjrefresh = ref}
                  onRefresh={
                  ()=>{
                      this.setState({
                          text:'正在刷新'
                      })
                      console.log('onRefresh')
                      setTimeout(()=>{
                          this._mjrefresh && this._mjrefresh.finishRefresh();
                      },1000)
                  }
                  }
                  onRefreshIdle={()=>console.log('onRefreshIdle')}
                  onReleaseToRefresh={()=>{
                      this.setState({
                          text:'释放刷新'
                      })
                  }}
                  onPulling={e=>{
                      if(e.nativeEvent.percent<0.1){
                          this.setState({
                              text:'下拉刷新'
                          })
                      }
                  }}
              >
                <View style={{height:100,backgroundColor:'red',
                    justifyContent:'center',
                    alignItems:'center',flexDirection:'row'
                }}>
                  <Text>{this.state.text}</Text>
                </View>
              </MJRefresh>
            }
        >
          <View style={{flex:1,height:1000,backgroundColor:'#ddd'}}>
          </View>
        </ScrollView>
    );
  }

MJRefresh

查看属性

查看方法

文档

Props

onReleaseToRefresh

可释放刷新时触发

| Type | Required | | ---- | -------- | | function | No |


onRefresh

刷新时触发

| Type | Required | | ---- | -------- | | function | No |


onRefreshIdle

刷新闲置时触发

| Type | Required | | ---- | -------- | | function | No |


onPulling

   ({nativeEvent: {percent:number}})=>void;

header下拉过程中触发

| Type | Required | | ---- | -------- | | function | No |

Methods

beginRefresh

   beginRefresh();

开始刷新


finishRefresh

   finishRefresh();

结束刷新

示例