{"id":26222691,"url":"https://github.com/rt2zz/react-native-drawer","last_synced_at":"2025-03-12T17:01:58.197Z","repository":{"id":30246472,"uuid":"33797700","full_name":"root-two/react-native-drawer","owner":"root-two","description":"React Native Drawer","archived":false,"fork":false,"pushed_at":"2022-04-09T01:31:28.000Z","size":10296,"stargazers_count":2532,"open_issues_count":186,"forks_count":389,"subscribers_count":51,"default_branch":"master","last_synced_at":"2025-03-08T09:34:58.766Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/root-two.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-12T00:34:59.000Z","updated_at":"2025-02-11T15:48:02.000Z","dependencies_parsed_at":"2022-07-19T00:32:15.185Z","dependency_job_id":null,"html_url":"https://github.com/root-two/react-native-drawer","commit_stats":null,"previous_names":["rt2zz/react-native-drawer","rt2zz/rn-drawer"],"tags_count":66,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-two%2Freact-native-drawer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-two%2Freact-native-drawer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-two%2Freact-native-drawer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/root-two%2Freact-native-drawer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/root-two","download_url":"https://codeload.github.com/root-two/react-native-drawer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243258487,"owners_count":20262298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-12T17:01:41.386Z","updated_at":"2025-03-12T17:01:58.111Z","avatar_url":"https://github.com/root-two.png","language":"JavaScript","funding_links":[],"categories":["Components"],"sub_categories":["UI"],"readme":"\n### USAGE WARNING\nThis module is not as performant as it should be. For production applications we generally recommend using either [React Native Side Menu](https://github.com/react-native-community/react-native-side-menu) or [React Navigation](https://github.com/react-navigation/react-navigation) as applicable. React Native Drawer will continue to be available and potentially useful for its high customizability but again it is **not** recommended for production appliciations. If you are interested in revamping react native drawer to be more performant (i.e. use Animated) please get in touch!\n\n\n## React Native Drawer\n\u003cimg width=\"220px\" align=\"right\" src=\"https://raw.githubusercontent.com/rt2zz/react-native-drawer/master/examples/rn-drawer.gif\" /\u003e\n\nReact native drawer, configurable to achieve material design style, slack style, parallax, and more. Works in both iOS and Android.\n\n[![npm version](https://img.shields.io/npm/v/react-native-drawer.svg?style=flat-square)](https://www.npmjs.com/package/react-native-drawer)\n[![npm downloads](https://img.shields.io/npm/dm/react-native-drawer.svg?style=flat-square)](https://www.npmjs.com/package/react-native-drawer)\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Examples](#examples)\n- [Props](#props)\n- [Demo](#demo)\n- [Credits](#credits)\n\n### Installation\n`npm install --save react-native-drawer`\n\n### Usage\n```javascript\nimport Drawer from 'react-native-drawer'\n\nclass Application extends Component {  \n  closeControlPanel = () =\u003e {\n    this._drawer.close()\n  };\n  openControlPanel = () =\u003e {\n    this._drawer.open()\n  };\n  render () {\n    return (\n      \u003cDrawer\n        ref={(ref) =\u003e this._drawer = ref}\n        content={\u003cControlPanel /\u003e}\n        \u003e\n        \u003cMainView /\u003e\n      \u003c/Drawer\u003e\n    )\n  }\n})\n```\n\n### Examples\n```js\n//Parallax Effect (slack style)\n\u003cDrawer\n  type=\"static\"\n  content={\u003cControlPanel /\u003e}\n  openDrawerOffset={100}\n  styles={drawerStyles}\n  tweenHandler={Drawer.tweenPresets.parallax}\n  \u003e\n    \u003cMain /\u003e\n\u003c/Drawer\u003e\n\n//Material Design Style Drawer\n\u003cDrawer\n  type=\"overlay\"\n  content={\u003cControlPanel /\u003e}\n  tapToClose={true}\n  openDrawerOffset={0.2} // 20% gap on the right side of drawer\n  panCloseMask={0.2}\n  closedDrawerOffset={-3}\n  styles={drawerStyles}\n  tweenHandler={(ratio) =\u003e ({\n    main: { opacity:(2-ratio)/2 }\n  })}\n  \u003e\n    \u003cMain /\u003e\n\u003c/Drawer\u003e\n\nconst drawerStyles = {\n  drawer: { shadowColor: '#000000', shadowOpacity: 0.8, shadowRadius: 3},\n  main: {paddingLeft: 3},\n}\n```\n\n### Props\nThis module supports a wide range of drawer styles, and hence has *a lot* of props.\n##### Important\n- `content` (React.Component) `null` - Menu component\n- `type` (String: displace:overlay:static) `displace`- Type of drawer.\n- `open` (Boolean) `null` - If true will trigger drawer open, if false will trigger close.\n- `openDrawerOffset` (Number|Function) `0` - Can either be a integer (pixel value) or decimal (ratio of screen width). Defines the right hand margin when the drawer is open. Or, can be function which returns offset: `(viewport) =\u003e viewport.width - 200`\n- `closedDrawerOffset` (Number|Function) `0` - Same as openDrawerOffset, except defines left hand margin when drawer is closed.\n- `disabled` (Boolean) `false` - If true the drawer can not be opened and will not respond to pans.\n- `styles` (Object) `null` - Styles for the drawer, main, drawerOverlay and mainOverlay container Views.\n\n##### Animation / Tween\n**Note**: In the future animations with use Animated, and the api will change.\n- `tweenHandler` (Function) `null` - Takes in the pan ratio (decimal 0 to 1) that represents the tween percent. Returns an object of native props to be set on the constituent views { drawer: {/*native props*/}, main: {/*native props*/}, mainOverlay: {/*native props*/} }\n- `tweenDuration` (Integer) `250` - The duration of the open/close animation.\n- `tweenEasing` (String) `linear` - A easing type supported by [tween-functions](https://www.npmjs.com/package/tween-functions)\n\n##### Event Handlers\n- `onOpen` (Function) - Will be called immediately after the drawer has entered the open state.\n- `onOpenStart` (Function) callback fired at the start of an open animation.\n- `onClose` (Function) - Will be called immediately after the drawer has entered the closed state.\n- `onCloseStart` (Function) callback fired at the start of a close animation.\n\n##### Gestures\n- `captureGestures` (oneOf(true, false, 'open', 'closed')) `open` - If true, will capture all gestures inside of the pan mask. If 'open' will only capture when drawer is open.\n- `acceptDoubleTap` (Boolean) `false` - Toggle drawer when double tap occurs within pan mask?\n- `acceptTap` (Boolean) `false` - Toggle drawer when any tap occurs within pan mask?\n- `acceptPan` (Boolean) `true` - Allow for drawer pan (on touch drag). Set to false to effectively disable the drawer while still allowing programmatic control.\n- `tapToClose` (Boolean) `false` - Same as acceptTap, except only for close.\n- `negotiatePan` (Boolean) `false` - If true, attempts to handle only horizontal swipes, making it play well with a child `ScrollView`.\n\n##### Additional Configurations\n- `panThreshold` (Number) `.25` - Ratio of screen width that must be travelled to trigger a drawer open/close.\n- `panOpenMask` (Number) `null` - Ratio of screen width that is valid for the start of a pan open action. If null -\u003e defaults to `max(.05, closedDrawerOffset)`.\n- `panCloseMask` (Number) `null` - Ratio of screen width that is valid for the start of a pan close action. If null -\u003e defaults to `max(.05, openDrawerOffset)`.\n- `initializeOpen` (Boolean) `false` - Initialize with drawer open?\n- `side` (String left|right|top|bottom) `left` - which side the drawer should be on.\n- `useInteractionManager` (Boolean) `false` - if true will run InteractionManager for open/close animations.\n- `elevation` (Number) `0` - (Android-only) Sets the elevation of the drawer using Android's underlying [elevation API](https://developer.android.com/training/material/shadows-clipping.html#Elevation)\n\n### Tween Handler\nYou can achieve pretty much any animation you want using the tween handler with the transformMatrix property. E.G.\n```js\ntweenHandler={(ratio) =\u003e {\n  var r0 = -ratio/6\n  var r1 = 1-ratio/6\n  var t = [\n             r1,  r0,  0,  0,\n             -r0, r1,  0,  0,\n             0,   0,   1,  0,\n             0,   0,   0,  1,\n          ]\n  return {\n    main: {\n      style: {\n        transformMatrix: t,\n        opacity: 1 - ratio/2,\n      },\n    }\n  }\n}}\n```\nWill result in a skewed fade out animation.\n\n### Opening \u0026 Closing the Drawer Programmatically\nThree options:\n\n1. Use the open prop (controlled mode):  \n\n    ```js\n    \u003cDrawer\n      open={true}\n    ```\n\n2. Using the Drawer Ref:\n\n    ```js\n    // assuming ref is set up on the drawer as (ref) =\u003e this._drawer = ref\n    onPress={() =\u003e {this._drawer.open()}}\n    ```\n\n3. Using Context\n\n    ```js\n    contextTypes = {drawer: React.PropTypes.object}\n    // later...\n    this.context.drawer.open()\n    ```\n\n### Demo\n* `git clone https://github.com/rt2zz/react-native-drawer.git`\n* `cd react-native-drawer/examples/RNDrawerDemo \u0026\u0026 npm install`\n* **iOS**\n\t* Open `./examples/RNDrawerDemo/RNDrawerDemo.xcodeproject` in xcode\n\t* `command+r` (in xcode)\n* **Android**\n\t* Run android simulator / plug in your android device\n\t* Run `react-native run-android` in terminal\n\n### Credits\nComponent was adapted from and inspired by\n[@khanghoang](https://github.com/khanghoang)'s [RNSideMenu](https://github.com/khanghoang/RNSideMenu)\n*AND*\n[@kureevalexey](https://twitter.com/kureevalexey)'s [react-native-side-menu](https://github.com/Kureev/react-native-side-menu)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frt2zz%2Freact-native-drawer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frt2zz%2Freact-native-drawer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frt2zz%2Freact-native-drawer/lists"}