Git Product home page Git Product logo

react-native-ezsidemenu's Introduction

react-native-ezsidemenu

中文文档

NPM version release GitHub license

customizable side menu for React Native on iOS&android.

Installation

$ npm install react-native-ezsidemenu --save

Preview

default type

defaultIos defaultAndroid

overlay type

overlayIos overlayAndroid

slide type

slideIos slideAndroid

Usage

import library:

import EZSideMenu from 'react-native-ezsidemenu';

simple

//App.js
simpleMenu() {
    return <EZSideMenu
      menu={this.menu()}
      ref="menu">
      {this.contentView()}
    </EZSideMenu>
  }

advanced

//App.js
  advancedMenu() {
    const menuWidth = DEVICE_SCREEN.width * 0.8;
    const opacity = this.state.animation.interpolate({
      inputRange: [0, menuWidth],
      outputRange: [0, 1],
    });
    return <EZSideMenu
      onMenuStateChaned={(isOpen) => { this.setState({ isOpen }) }}
      onPanMove={(x) => { console.log('onPanMove ' + x) }}
      onSliding={(x, persent) => { console.log('onSliding x ' + x + ' persent ' + persent) }}
      type={EZSideMenu.type.Default}
      menuStyle={styles.container}
      shadowStyle={{ backgroundColor: 'rgba(20,20,20,.7)' }}
      direction={EZSideMenu.direction.Right}
      ref="menu"
      position={this.state.animation}
      width={menuWidth}
      menu={this.menu(opacity)}
      animationFunction={(prop, value) => Animated.spring(prop, {
        friction: 10,
        toValue: value
      })}>
      {this.contentView()}
    </EZSideMenu>
  }

API

Props

key type default description
menu PropTypes.object.isRequired menu component
shadowStyle View.propTypes.style { backgroundColor: 'rgba(0,0,0,.4)' } the style of the menu sahdow
menuStyle View.propTypes.style {} the style of the menu
direction PropTypes.string direction.Left the direction of the menu
type PropTypes.string type.Default the animation of the menu
position PropTypes.object new Animated.Value(0) the distance of the menu
width PropTypes.number DEVICE_SCREEN.width * 0.7 the width of the menu
animationFunction PropTypes.func animationFunction: (prop, value) => Animated.timing(prop, {
easing: Easing.inOut(Easing.ease),
duration: 300,
toValue: value
}),
the animation of the menu
panGestureEnabled PropTypes.bool true the menu can be move with gestures or not
panWidthFromEdge PropTypes.number 60 edge distance on content view to open side menu
panTolerance PropTypes.object { x: 6, y: 20 } pan move tolerance
onPanStartMove PropTypes.func callback on menu start move
onPanMove PropTypes.func callback on menu move
onPanEndMove PropTypes.func callback on menu end move
onSliding PropTypes.func callback on menu is sliding
onMenuStateChaned PropTypes.func callback on menu state is chaned

Function

function description
open() open menu
close() close menu

License

MIT License. © Zhu Yangjun 2017

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.