GithubHelp home page GithubHelp logo

felix98765 / react-simple-pull-to-refresh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thmsgbrt/react-simple-pull-to-refresh

0.0 0.0 0.0 2.02 MB

npm install react-simple-pull-to-refresh

Home Page: https://www.npmjs.com/package/react-simple-pull-to-refresh

License: MIT License

JavaScript 34.11% TypeScript 52.10% CSS 4.97% HTML 3.92% SCSS 4.89%

react-simple-pull-to-refresh's Introduction

react-simple-pull-to-refresh

npm version license

A Simple Pull-To-Refresh Component for React Application with 0 dependency. Works for Mobile and Desktop.

Contributing

โš ๏ธ I don't have much time to take care of the issues at the moment.

๐Ÿ™ Any help and contribution is greatly appreciated.

Demo

Click here ๐Ÿ‘

Installation

npm i react-simple-pull-to-refresh

Usage

import PullToRefresh from 'react-simple-pull-to-refresh';

Pull To Refresh only

// ...

return (
  <PullToRefresh onRefresh={handleRefresh}>
    <ul>
      {list.map((item, index) => (
        <li key={index}>{item}</li>
      ))}
    </ul>
  </PullToRefresh>
);

// ...

Pull To Refresh and Fetch More enabled

// ...

return (
  <PullToRefresh onRefresh={handleRefresh} canFetchMore={true} onFetchMore={handleFetchMore}>
    <ul>
      {list.map((item, index) => (
        <li key={index}>{item}</li>
      ))}
    </ul>
  </PullToRefresh>
);

// ...

Props Matrix

Name Type Required Default Description
isPullable boolean false true Enable or disable pulling feature
onRefresh () => Promise true Function called when Refresh Event has been trigerred
pullDownThreshold number false 67 Distance in pixel to pull to trigger a Refresh Event
maxPullDownDistance number false 95 Maximum transitionY applied to Children when dragging
resistance number false 1 Scale of difficulty to pull down
refreshingContent JSX.Element or string false Content displayed when Pulling or Fetch more has been trigerred
pullingContent JSX.Element or string false Content displayed when Pulling
canFetchMore boolean false false Enable or disable fetching more feature
onFetchMore () => Promise false Function called when Fetch more Event has been trigerred
fetchMoreThreshold number false 100 Distance in pixel from bottom of the container to trigger a Fetch more Event
backgroundColor string false Apply a backgroundColor
className string false

Changelog

1.3.3: Update package.json peerDependencies to support react 18 - (From: @mjauernig)

1.3.2: Fix build issue encountered with 1.3.1

1.3.1: Fix issue preventing fixed elements to work properly - (From: @ManuDoni)

1.3.0: Add a resistance prop, that allows to adjust the pull down difficulty - (From: @joshuahiggins)

1.2.5: Fix event listenter leaks - (From: @d-s-x)

1.2.4: Fix overscroll on iOS Safari - (From: @d-s-x)

1.2.3: Add React 17+ as valid peer dependencies - (From: @Felixmosh)

1.2.2: Remove non-null assertion operators from ref.current + TouchEvent check for Mozilla - (From: @HamAndRock)

1.2.1: Remove unnecessary z-index

1.2.0: onRefresh and onFetchMore now require to be of type () => Promise

1.1.2: Bind Scroll event to Window

1.1.0: Check for "canFetchMore" value for each scroll events.

1.1.0: Add a Fetch More feature

react-simple-pull-to-refresh's People

Contributors

d-s-x avatar dependabot[bot] avatar felixmosh avatar hamandrock avatar joshuahiggins avatar manudoni avatar mjauernig avatar thmsgbrt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.