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-swipe-down-refresh

v0.1.1

Published

React swipe down to refresh component

Downloads

51

Readme

react-swipe-down-refresh

npm version license

Swipe down to refresh or pull-to-refresh control for mobile web applications.

The component is built using composable utilities to give fine grain control over the swipe-refresh behavior. These building blocks could be used independently to build your own swipe-refresh control.

Components and utils

  • SwipeRefreshList—React component with swipe-refresh behavior
  • useSwipeRefresh—React hook that encapsulates the swipe-refresh logic
  • SwipeRefreshCoordinator—UI framework agnostic implementation of the core gesture handling logic

Getting started


To start using react-swipe-down-refresh, install it via NPM

npm i react-swipe-down-refresh

# yarn
yarn add react-swipe-down-refresh

Demo


Try it online


Open in a mobile web-browser or toggle the device mode on a web-browser

Try the app online here.

Usage


Import the SwipeRefreshList component and include the styles provided in the package to get the swipe-refresh behavior. Make sure your build system supports importing .css files.

import { SwipeRefreshList } from "react-swipe-down-refresh";

// include the styles
import "react-swipe-down-refresh/lib/styles.css";

export default function App() {
  const onRefreshRequested = () => {
    return new Promise<void>((resolve) => {
      setTimeout(() => resolve(), 3000);
    });
  };

  return (
    <div>
      <SwipeRefreshList onRefresh={onRefreshRequested}>
        <div className="item">Line 1</div>
        <div className="item">Line 2</div>
        <div className="item">Line 3</div>
      </SwipeRefreshList>
    </div>
  );
}

Props

| Name | Description | Required | Default | | :-------: | :---------------------------------------: | :------: | :-----: | | onRefresh | Callback function triggered on refresh | true | - | | disabled | Disabled pull to refresh | false | false | | className | CSS class to attache to the outermost div | false | - |

Customization

You can customize the swipe refresh spinner look and behavior via the following the props

| Name | Description | Required | Default | | :---------------------: | :---------------------------------------------------------------------: | :------: | :-----: | | threshold | Minimum gesture movement displacement before swipe action is registered | false | false | | onEndRefresh | Callback function triggered on refresh is complete | false | false | | onStartRefresh | Callback function triggered on refresh start | false | false | | slingshotDistance | The distance the refresh indicator can be pulled during a swipe gesture | false | false | | progressViewOffset | The refresh indicator position during refresh | false | false | | progressStrokeColor | Color of the refresh progress spinner | false | false | | getScrollTopOverride | Disabled pull to refresh | false | false | | overrideBrowserRefresh | Override browser pull to refresh behaviour | false | false | | progressBackgroundColor | Background color of the progress spinner | false | false |

Credits