vvavepacket
vvavepacket

Reputation: 1929

Drawer is not triggered when swiping to the right

I'm using react native-base and I'm trying to swipe my screen to the right to show the drawer. I'm expecting to see this while swiping:

enter image description here

Below is my code,

import React, { Component } from 'react'
import { Drawer, View } from 'native-base'
import { Navigator } from 'react-native'

export default class AppContainer extends Component {
  constructor(props) {
    super(props)
    this.state = {
      toggled: false,
      store: {},
      theme: null
    }
  }
  toggleDrawer() {
    this.state.toggled ? this._drawer.close() : this._drawer.open()
  }
  openDrawer() {
    this.setState({toggled: true})
  }
  closeDrawer() {
    this.setState({toggled: false})
  }
  renderScene(route, navigator) {
    switch(route) {
      default: {
        return null
      }
    }
  }
  configureScene(route, routeStack) {
    return Navigator.SceneConfigs.PushFromRight
  }
  render() {
    return (
      <Drawer
        ref={(ref) => this._drawer = ref}
        type="displace"
        content={<View style={{backgroundColor: "#000", height: 1000}}/>}
        onClose={this.closeDrawer.bind(this)}
        onOpen={this.openDrawer.bind(this)}
        openDrawerOffset={0.2}
        >
          <Navigator
            ref={(ref) => this._navigator = ref}
            configureScene={this.configureScene.bind(this)}
            renderScene={this.renderScene.bind(this)}
            />
        </Drawer>
    )
  }
}

When we run this code, all we get is a blank screen. I tried swiping to the right but drawer doesn't appear.

enter image description here

As we can see, I'm returning the Drawer component in the render function, but when I try to swipe it, the drawer doesn't appear. I tried to run it on Android both on physical device and virtual device and they dont activate the drawer. What might be the issue?

Upvotes: 0

Views: 664

Answers (1)

Michio
Michio

Reputation: 66

Within the Drawer component after

openDrawerOffset={0.2}

Add the following:

panOpenMask={0.80}
captureGestures="open"

Upvotes: 1

Related Questions