Git Product home page Git Product logo

Comments (18)

rt2zz avatar rt2zz commented on August 20, 2024

Off the top of my head, you can probbly accomplish this setting acceptTap = true when the drawer is open, and then setting false when it is closed.

To do this however you would need to keep track of wether the drawer is open or not. This is possible using the onOpen/onClose props. e.g. using local component state:

  <Drawer
    onOpen={() => this.setState({drawerState: 'open'})
    onClose={() => this.setState({drawerState: 'closed'})
    acceptTap={this.state.drawerState === 'open' ? true : false}
    //...
    />

Using flux/redux you can do something similar but instead of setState fire an action.

Let me know if that works. Since this is a common use case (material design) I would definitely consider changing the API or adding another prop to better support this. Let me know if you have suggestions on what the props should look like.

from react-native-drawer.

Mokto avatar Mokto commented on August 20, 2024

Thank for your quick answer.

Your solution is much cleaner but it doesn't prevent Touchable elements within the pan mask to be touched.

capture d ecran 2015-09-24 a 22 41 04

from react-native-drawer.

Mokto avatar Mokto commented on August 20, 2024

I could use your solution to prevent every Touchable to be touched too but I don't think it is very "clean"

from react-native-drawer.

rt2zz avatar rt2zz commented on August 20, 2024

good point, I think then captureGestures = true will fix that problem.

from react-native-drawer.

Mokto avatar Mokto commented on August 20, 2024

Ok, thanks.

Actually, I think the behaviour is not right with captureGestures. I might be wrong ^^ but this is my workflow :

  • captureGestures={false} : when I click on a Touchable within the pan mask, the Touchable event is called
  • captureGestures={true} : when I click on a Touchable within the pan mask, the Touchable event is called AND the drawer is closed

from react-native-drawer.

rt2zz avatar rt2zz commented on August 20, 2024

ah, sounds like a bug. I am on my phone, I will have to look into it further tomorrow

from react-native-drawer.

rt2zz avatar rt2zz commented on August 20, 2024

I just did a test and it works for me (v1.3.0)

captureGestures={true} results in anything under the mask from not being touched. Can you double check your settings?

To be clear, in the screenshot above, the left hand side is the drawer and the small section on the right is the main view correct? Also what component is managing the 'touchable' event, is it TouchableHighlight?

from react-native-drawer.

Mokto avatar Mokto commented on August 20, 2024

To be clear, in the screenshot above, the left hand side is the drawer and the small section on the right is the main view correct? YES
Also what component is managing the 'touchable' event, is it TouchableHighlight? YES

EDIT : But you should know that I used acceptPan={false} to make the drawer open only on click.

from react-native-drawer.

rt2zz avatar rt2zz commented on August 20, 2024

Ah, yes accepPan was not playing well with captureGestures. I just fixed it in this commit: f4caf4e

I have not tested it enough to feel comfortable making a new npm release, but you should be able to pull the latest from github. Let me know how it goes.

from react-native-drawer.

Mokto avatar Mokto commented on August 20, 2024

Hum, in my case it's like there is an invisible pan preventing me from touching anything on the left side.

<Drawer ref="drawer"
              acceptPan={false}
              onOpen={() => this.setState({drawerState: 'open'})}
              onClose={() => this.setState({drawerState: 'closed'})}
              acceptTap={this.state.drawerState === 'open' ? true : false}
              captureGestures={true}
              content={<DrawerContent></DrawerContent>}
              type="static"
              openDrawerOffset={DRAWER_OFFSET}
              tweenDuration={150}>
</Drawer>

capture d ecran 2015-09-25 a 15 00 10

from react-native-drawer.

rt2zz avatar rt2zz commented on August 20, 2024

right, this is the expected behaivor. You are probably going to want to set panOpenMask={0}. Alternatively (depending on your exact desired behaivor) you can set captureGestures={this.state.drawerState === 'open' ? true : false}

<Drawer ref="drawer"
              panOpenMask={0}
              acceptPan={false}
              onOpen={() => this.setState({drawerState: 'open'})}
              onClose={() => this.setState({drawerState: 'closed'})}
              acceptTap={this.state.drawerState === 'open' ? true : false}
              captureGestures={true}
              content={<DrawerContent></DrawerContent>}
              type="static"
              openDrawerOffset={DRAWER_OFFSET}
              tweenDuration={150}>
</Drawer>

from react-native-drawer.

Mokto avatar Mokto commented on August 20, 2024

Works perfectly ! Thanks a lot ! πŸ˜ƒ

from react-native-drawer.

Mokto avatar Mokto commented on August 20, 2024

Hi,
I just updated to 1.4.2 and the bug is still present (should be fixed in commit f4caf4e)

Thanks !

from react-native-drawer.

rt2zz avatar rt2zz commented on August 20, 2024

Can you elaborate on what exactly is not working as expected? We discussed a few things in this thread :)

from react-native-drawer.

Mokto avatar Mokto commented on August 20, 2024

Sure !

image

You response was :

Ah, yes accepPan was not playing well with captureGestures. I just fixed it in this commit: f4caf4e

I have not tested it enough to feel comfortable making a new npm release, but you should be able to pull the latest from github. Let me know how it goes.

The problem it that combining acceptPan and captureGestures, i can click on TouchableHighlight on the right side.

from react-native-drawer.

rt2zz avatar rt2zz commented on August 20, 2024

thank you for your awesome screenshots πŸ‘

You are right, I inexplicably rolled that back in a later commit. I will fix and cut a new release shortly.

from react-native-drawer.

rt2zz avatar rt2zz commented on August 20, 2024

fixed 175249f

from react-native-drawer.

Mokto avatar Mokto commented on August 20, 2024

Perfect ! Thanks ;)

from react-native-drawer.

Related Issues (20)

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.