react-native - 在视图中滚动时禁用滚动反应本机
问题描述
我在滚动视图中有几个视图组件,但是一个视图在画布上具有绘图功能,我想在画布上绘图时禁用滚动,但在其他视图上不这样做。我一无所知,任何帮助将不胜感激。
<ScrollView>
<View>
//allow scrolling while pulling on component
</View>
<View>
<Canvas />
//dont allow scrolling while pulling on component
</View>
<View>
//allow scrolling while pulling on component
</View>
<View>
//allow scrolling while pulling on component
</View>
</ScrollView>
解决方案
export default function Component (){
const [scrollEnabled, setScrollEnabled] = useState(true);
return (
<ScrollView scrollEnabled={scrollEnabled}>
<View onPress={() => setScrollEnabled(false)} />
</ScrollView>
);
}
触摸组件时禁用滚动,不触摸时重新启用滚动。
推荐阅读
- scala - 如何在 elasticsearch 6.3.0 中创建 TransportClient 对象
- javascript - 无法生成 0 到 10 之间的随机数
- java - 如何在 java 中创建可用的 KeyReleased 方法
- php - PHP If 语句 if (!$_POST) - !$_POST 是什么意思?
- java - 如何使用@Transaction 和线程
- r - 创建矩阵行索引,当 rowsum > 100 和下一行时递增
- visual-studio - 如何在 Visual Studio 2017 中克隆解决方案(使用不同的名称)?
- android - 背景图片不显示在手机上
- c# - 为 WPF CustomControl 设置默认 ControlTemplate
- tensorflow - 既然我们有了 Tensorflow Serving,“Tensorflow Distibuted”到底是什么?