React原生DrawerLayoutAndroid和Switch组件不能很好地工作

时间:2022-09-22 18:58:04

I have a switch component on DrawerLayoutAndroid component. When I drag the switch component, drawer component is being slided.

我在DrawerLayoutAndroid组件上有一个开关组件。当我拖动开关组件时,抽屉组件正在滑动。

How do I ensure when i drag switch, drawer panel is in blocked mode.

如何确保拖动开关时,抽屉面板处于阻塞模式。

[EDIT] Attaching the mocks below Mocks

[编辑]在Mocks下方附加嘲笑

1 个解决方案

#1


0  

Usually a tap on the Switch will toggle the switch state. If you want to make it drag as well and not let the other view become the responder, you can do that by implementing GestureResponseHandler. Something like this.

通常,在Switch上点击将切换开关状态。如果你想让它拖动而不让其他视图成为响应者,你可以通过实现GestureResponseHandler来实现。像这样的东西。

const RespondHandler = {
 onStartShouldSetResponder: function (e) {
    return true;
 },
 onResponderGrant: function (e) {
    return true;
 }
};

<Switch {...RespondHandler}/>

#1


0  

Usually a tap on the Switch will toggle the switch state. If you want to make it drag as well and not let the other view become the responder, you can do that by implementing GestureResponseHandler. Something like this.

通常,在Switch上点击将切换开关状态。如果你想让它拖动而不让其他视图成为响应者,你可以通过实现GestureResponseHandler来实现。像这样的东西。

const RespondHandler = {
 onStartShouldSetResponder: function (e) {
    return true;
 },
 onResponderGrant: function (e) {
    return true;
 }
};

<Switch {...RespondHandler}/>