Code Monkey home page Code Monkey logo

rn-sliding-up-panel's Introduction

Sliding up panel npm

React Native draggable sliding up panel purly implemented in Javascript. Inspired by AndroidSlidingUpPanel. Works nicely on both iOS and Android.

Installation

npm install --save rn-sliding-up-panel

or if you are using yarn

yarn add rn-sliding-up-panel

Example

import React from 'react';
import {View, Button, Text} from 'react-native';

import SlidingUpPanel from 'rn-sliding-up-panel';

const styles = {
  container: {
    flex: 1,
    backgroundColor: 'white',
    alignItems: 'center',
    justifyContent: 'center'
  }
}

class MyComponent extends React.Component {
  state = {
    visible: false
  }

  render() {
    return (
      <View style={styles.container}>
        <Button title='Show panel' onPress={() => this.setState({visible: true})} />
        <SlidingUpPanel
          visible={this.state.visible}
          onRequestClose={() => this.setState({visible: false})}>
          <View style={styles.container}>
            <Text>Here is the content inside panel</Text>
            <Button title='Hide' onPress={() => this.setState({visible: false})} />
          </View>
        </SlidingUpPanel>
      </View>
    )
  }
}

Props

Property Type Description
visible boolean Deterimines whether the panel is visible.
draggableRange {top: number, bottom: number} Boundary limits for draggable area. top default to visible height of device, bottom default to 0.
height number Height of panel. Default to visible height of device.
onRequestClose Function Called when you touch the backdrop or slide down to hide the panel.
onDragStart (position: number) => void Called when the panel is about to start dragging.
onDrag (position: number) => void Called when the panel is dragging. Fires at most once per frame.
onDragEnd (position: number) => void Called when you release your finger.
showBackdrop boolean Controls the visibility of backdrop. Default true.
allowDragging boolean Default true. Setting this to false to disable dragging. Touching the backdrop triggers onRequestClose normally.
allowMomentum boolean If false, panel will not continue to move when you release your finger.
contentStyle ViewStyle The style of content inside panel. Deprecated. You should wrap your content inside a View.
children React.Element | Function Accepts passing a function as component. Invoked with dragHandlers (that can be passed into another View like this <View {...dragHandlers}>) when the panel is mounted. Useful when you want a part of your content that allows the user to slide the panel with.

Notes:

  • All properties are optional.

Methods

transitionTo: (value: number | TimingAnimationConfig)

Programmatically move panel to a given value. Accepts a number or an object that may have the following options:

  • toValue: The value that the panel will move to.
  • duration: Length of animation (milliseconds). Default is 260.
  • easing: Easing function to define curve. Default is Easing.inOut(Easing.ease).
  • onAnimationEnd: A callback that will be called when the animation is done.

Advanced Usage

In progress.

Changelogs

1.2.0

  • Accept function as children. Allow a part of content becomes drag handlers.
  • Fix issue can not interact with components underlies the panel.

rn-sliding-up-panel's People

Contributors

bramus avatar jaycee425 avatar octopitus avatar samschooler avatar

Watchers

 avatar  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.