gpt4 book ai didi

reactjs - NativeBase 抽屉滑动不起作用

转载 作者:行者123 更新时间:2023-12-02 18:50:59 28 4
gpt4 key购买 nike

有人可以告诉我这段代码有什么问题吗?当我运行模拟器时,它运行良好,但当我滑动以调出内容时,它不会显示。抽屉不能用。我做错了什么?

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

export default class DrawerExample 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={100}
>
<Navigator
ref={(ref) => this._navigator = ref}
configureScene={this.configureScene.bind(this)}
renderScene={this.renderScene.bind(this)}
/>
</Drawer>
);
}
}

最佳答案

您可以通过panOpenMask={<value>}来实现这一点。我测试它的值为.25 .

API说:

panOpenMask (Number) null - Ratio of screen width that is valid for the start of a pan open action. If null -> defaults to max(.05, closedDrawerOffset)

编辑:

我的完整代码(在我自己的项目中)是:

<Drawer
ref={(ref) => { this._drawer = ref; }}
content={ navigationView }
side="right"
panOpenMask={.25}
>

关于reactjs - NativeBase 抽屉滑动不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42384210/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com