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-swipeable-row-bouncing

v0.8.1

Published

A powerful React Native swipe component based on @jshanson7 package

Downloads

5

Readme

React Native Swipeable NPM version

A powerful React Native swipe component. Supports both iOS and Android.

Installation

npm i --save react-native-swipeable-row

Usage

Wrap your ListView/TableView items with the Swipeable component:

import Swipeable from 'react-native-swipeable-row';

const leftContent = <Text>Pull to activate</Text>;

const rightButtons = [
  <TouchableHighlight><Text>Button 1</Text></TouchableHighlight>,
  <TouchableHighlight><Text>Button 2</Text></TouchableHighlight>
];

function MyListItem() {
  return (
    <Swipeable leftContent={leftContent} rightButtons={rightButtons}>
      <Text>My swipeable content</Text>
    </Swipeable>
  );
}

Props

| prop | type | default | description | |---------------------------------|--------------|---------|-------------------------------------------------------------------------------------------| | children | renderable | null | swipeable content | | leftContent | renderable | null | (optional) left content visible during pull action | | rightContent | renderable | null | (optional) right content visible during pull action | | leftButtons | renderable[] | null | (optional) array of buttons, first being the innermost; ignored if leftContent present | | rightButtons | renderable[] | null | (optional) array of buttons, first being the innermost; ignored if rightContent present | | leftActionActivationDistance | integer | 125 | (optional) minimum swipe distance to activate left action | | onLeftActionRelease | function | null | (optional) user has swiped beyond leftActionActivationDistance and released | | rightActionActivationDistance | integer | 125 | (optional) minimum swipe distance to activate right action | | onRightActionRelease | function | null | (optional) user has swiped beyond rightActionActivationDistance and released | | leftButtonWidth | integer | 75 | (optional) resting visible peek of each left button after buttons are swiped open | | rightButtonWidth | integer | 75 | (optional) resting visible peek of each right button after buttons are swiped open | | onRef | function | null | (optional) receive swipeable component instance reference | | onPanAnimatedValueRef | function | null | (optional) receive swipeable pan Animated.ValueXY reference for upstream animations | | bounceOnMount | boolean | false | (optional) To alert the user that swiping is possible | | bounceOnMountDuration | integer | 250 | (optional) Duration of the bounceOnMount animation | | disable | boolean | false | (optional) Disable swiping |

Advanced Props

Check out the Swipeable component's propTypes for a huge list of options including animation lifecycle hooks and low-level overrides.

Instance Methods

recenter()

Imperatively reset swipeable component back to initial position. This is useful if buttons are exposed and the user has begun scrolling the parent view.

class MyListItem extends Component {

  swipeable = null;

  handleUserBeganScrollingParentView() {
    this.swipeable.recenter();
  }

  render() {
    return (
      <Swipeable onRef={ref => this.swipeable = ref} rightButtons={rightButtons}>
        <Text>My swipeable content</Text>
      </Swipeable>
    );
  }
}

bounceRight(onDone)

Bounce the right component to alert swiping is possible. onDone is an optional callback.

bounceLeft(onDone)

Bounce the left component to alert swiping is possible. onDone is an optional callback.

Example

To run the example:

npm run build
cd example
npm install
react-native run-ios # or run-android

Common Issues

Action being triggered more than once (#3)

This seems to occur occasionally (but not always) with certain ScrollView and ListView configurations. The fix is simple though, just ensure that scrollEnabled is set to false while the user is swiping a row.

<ScrollView scrollEnabled={!this.state.isSwiping}>
  <Swipeable
    onSwipeStart={() => this.setState({isSwiping: true})}
    onSwipeRelease={() => this.setState({isSwiping: false})}
  </Swipeable>
</ScrollView>

or:

<ListView
  scrollEnabled={!this.state.isSwiping}
  renderRow={() => (
    <Swipeable
      onSwipeStart={() => this.setState({isSwiping: true})}
      onSwipeRelease={() => this.setState({isSwiping: false})}
    </Swipeable>
  )}
/>

License

MIT