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-sliding-panes

v1.0.3

Published

A simple set of React Native components that allow for views that slide in and out on command

Downloads

151

Readme

react-native-sliding-panes

A simple set of React Native components that allow for views that slide in and out on command. They can be wired up to a Gesture Recognizer for swiping, or to touchable highlights for quick navigation. Here is a quick view of the example project:

example

Installation

From a terminal navigate to your project folder and type:

npm install react-native-sliding-panes --save

or add the following line to your dependencies within package.json and then npm install

"react-native-sliding-panes": "1.0.3"

Usage

SlidingPane

The SlidingPane component can be used all on its own, or with any number of other SlidingPane instances within a SlidingPaneWrapper component.

To use SlidingPane by itself be sure to import the class at the top of the file you want to use it:

import {SlidingPane} from 'react-native-sliding-panes';

Then within your render method put the <SlidingPane> tag wherever you'd like it to appear. You can pass whatever styles you like to it just like it was a normal <View> tag. Be sure to create a ref to it as well so that you can use the member functions to animate it. Finally, place whatever content you want within just like it was a normal <View>:

<SlidingPane style={{ flex: 1, borderColor: 'red', borderWidth: '1' }} ref={ (myPane) => this.myPane = myPane }>
  <View>
    <Text>This is myPane</Text>
  </View>
</SlidingPane>

To animate the component there are a number of instance methods available on the ref you created for the component. For example if you want the pane to warp to the center without animating simply type this.myPane.warpCenter(). If you want the pane to slide off the right side of the screen simply type this.myPane.slideRight(). The list of methods available are:

  • warpLeft()
  • slideLeft()
  • warpCenter()
  • slideCenter()
  • warpRight()
  • slideRight()

SlidingPaneWrapper

You can use any number of SlidingPane components within a SlidingPaneWrapper to help you with managing multiple panes. Be sure to import both the SlidingPaneWrapper and SlidingPane components from your import statement:

import {SlidingPane, SlidingPaneWrapper} from 'react-native-sliding-panes';

Simply put the <SlidingPaneWrapper> tag wherever you would like your set of sliding panes to appear. Again, you can pass the wrapper whatever styles you like just as if it were a normal <View> tag. You will have to also create a ref to the wrapper so that you can use the member functions to animate the child panes. Here is an abbreviated sample, see the 'Example' folder code for a working example as demonstrated in the animated GIF above:

<SlidingPaneWrapper style={{ flex: 1 }} ref={(slidingPaneWrapper) => { this.slidingPaneWrapper = slidingPaneWrapper }}>
  <SlidingPane ref={ (pane1) => { this.pane1 = pane1} }>
      <View><Text>Pane 1</Text</View>
  </SlidingPane>
  <SlidingPane ref={ (pane2) => { this.pane2 = pane2} }>
      <View><Text>Pane 2</Text</View>
  </SlidingPane>
  <SlidingPane ref={ (pane3) => { this.pane3 = pane3} }>
      <View><Text>Pane 3</Text</View>
  </SlidingPane>
</SlidingPaneWrapper>

Within the component that contains the SlidingPaneWrapper, you will need a componentDidMount() method that sets up the sliding pane wrapper and the panes within. Here is an example:

componentDidMount() {
  this.pane1.warpCenter();
  this.pane2.warpRight();
  this.pane3.warpRight();
  this.slidingPaneWrapper.childPanes = [this.pane1, this.pane2, this.pane3];
}

Now you can use the SlidingPaneWrapper instance methods to move between the panes. For example you can use SlideAllLeft() for a swipe left motion that moves all the panes to the left. Or, you can use the setActive(index) method to select a specific chid pane and have the animation properly reflect the positioning of the panes (i.e. If the pane you are moving to is to the right of pane you were on, you will see the old pane slide off to the left while the new one slide in from the right). The list of methods available are:

  • slideAllLeft()
  • slideAllRight()
  • setActive(index)

Example Code

There is an simple React Native example project available within the 'Example' folder. If you want to run the example project and see the components in action simply check out the files, navigate to the 'Example' folder in a terminal, type npm install to install all the dependent modules, then type react-native run-ios or react-native run-android to see the example in action.