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

@landandan/react-native-pull-refresh

v1.0.2

Published

Custom pull to refresh component for Android

Downloads

6

Readme

Custom Android Pull to Refresh

Inspired by the shots from the author: https://dribbble.com/yupnguyen

Expo Demo

| Coffee Concept | Coin Concept | Weather Concept | ------------------------- |:-----------------------:|:-----------------------:| | Output sample|Output sample |Output sample|

Description

Currently, react-native provides RefreshControl out of the box. (Which uses standard circle android animation). https://facebook.github.io/react-native/docs/refreshcontrol.html.

However, it is not 'yet' possible to override the animation that runs during refreshing phase. This package aims to fill this gap and provide a 'relatively' easy way to add your own custom animation.

Installation

  1. Install the package using either:
$ npm install --save react-native-pull-refresh
# or
$ yarn add react-native-pull-refresh
  1. Install and link the Lottie package (renders Adobe After Effect animations): https://github.com/airbnb/lottie-react-native
yarn add lottie-react-native
# or
npm i --save lottie-react-native

react-native link lottie-react-native

Usage

This code is taken from examples/SimpleAnimations/weatherAnimation sample

You can find < Header /> and < ScrollItem /> components in the sample folder

import PullToRefresh from 'react-native-pull-refresh';

export default class weatherAnimation extends Component {
  constructor( ) {
    super( );
    this.state = {
      isRefreshing: false,
    };
  }

  onRefresh() {
    this.setState({isRefreshing: true});
    
    // Simulate fetching data from the server
    setTimeout(() => {
      this.setState({isRefreshing: false});
    }, 5000);
  }

  render() {
    return (
      <View style={{flex:1}}>
        <Header/>
        <View style={{flex: 7, backgroundColor: '#F8F4FC'}}>
          <PullToRefresh
            isRefreshing= {this.state.isRefreshing}
            onRefresh= {this.onRefresh.bind(this)}
            animationBackgroundColor = {'#564A63'}
            pullHeight = {180}
            contentView = {
              <ScrollView>
                <ScrollItem/>
                <ScrollItem/>
                <ScrollItem/>
                <ScrollItem/>
                <ScrollItem/>
                <ScrollItem/>
                <ScrollItem/>
                <ScrollItem/>
                <ScrollItem/>
              </ScrollView>
            }
            
            onPullAnimationSrc ={require('./umbrella_pull.json')}
            onStartRefreshAnimationSrc ={require('./umbrella_start.json')}
            onRefreshAnimationSrc = {require('./umbrella_repeat.json')}
            onEndRefreshAnimationSrc = {require('./umbrella_end.json')}
          />
        </View>
      </View>
    );
  }
}

Animation Files Format

Lottie JSON - https://github.com/airbnb/lottie-react-native

Lottie is a mobile library, developed by AirBnB for Android and iOS that parses Adobe After Effects animations exported as JSON with bodymovin and renders them natively on mobile.

Lottie allows to easily use animations in react-native apps. You just need to create an animation in Adobe After Effects and export it with bodymovin addon to AE https://github.com/bodymovin/bodymovin.

You can find file examples in examples/SimpleAnimations/animations folder

General Props

| Prop | Type | Description | |---|---|---| |isRefreshing|Boolean|Refresh state set by parent to trigger refresh.| |pullHeight|Integer|Pull Distance Default 180.| |onRefresh|Function|Callback after refresh event| |contentView|Object|The content: ScrollView or ListView| |animationBackgroundColor|string|Background color| |onScroll|Function|Custom onScroll event|

Animation Source Files Props

| Prop | Description | |---|---| |onPullAnimationSrc|Animation JSON that runs when scroll view is pulled down| |onStartRefreshAnimationSrc|Animation JSON that runs after view was pulled and released| |onRefreshAnimationSrc|Animation JSON that runs continuously until isRefreshing props is not changed| |onEndRefreshAnimationSrc|Animation JSON that runs after isRefreshing props is changed|

Demo

The demo app can be found at examples/SimpleAnimations.

Install Expo App on your Android smartphone

Scan this QR-code with your Expo App.

alt text

... or go here and try it out!

Contribution / Issues

Are very welcome! :)