android - React Native - 用户向下滚动足够多后,使视图出现并跟随屏幕,视图出现和消失太慢
问题描述
我有一个按钮,在用户在 ScrollView 中包含的长屏幕上向下滚动足够多后出现,我有一些代码并且它可以工作,但是视图需要一整秒才能出现和消失,这太慢了!有没有办法让它更快地出现和消失?
const [showBottomButton, setShowBottomButton] = useState(false)
.
const handleScroll = (event) => {
var curY = event.nativeEvent.contentOffset.y;
if (curY>=500 && !showBottomButton){
setShowBottomButton(true)
}else if (curY<500 && showBottomButton){
setShowBottomButton(false)
}
}
.
{showBottomButton ? <View style={{ position: 'absolute', left: 0, bottom: 0, right: 0, height: 70, alignItems: 'center', justifyContent: 'center', backgroundColor: 'white', borderTopWidth: 1, borderColor: '#eeeeee' }}>
<TouchableOpacity onPress={BottomButtonOnpress}>
<View style={styles.BottomButton}
<Text style={styles.MediumText}>Button Text</Text>
</View></TouchableOpacity>
</View> : null}
解决方案
推荐阅读
- f# - F#:将元组包装成多行
- tensorflow - 如何安装空间变压器
- javascript - 如何使用 reduce 合并 JavaScript 对象数组?
- vb.net - 检查图片框是否为空
- c# - Activator.CreateInstanceFrom..Unwrap(); 铸造类型失败
- java - 如何使用 where 子句更新 Spring Data JPA 中的表
- node.js - HTTPS 响应未在浏览器中设置 Cookie
- javascript - Google reCaptcha 验证弹出窗口未在 Mat Dialog 中正确显示
- python - 无论深度如何,在任意点修改列表的随机值
- matlab - 如何在循环之间延迟而不影响 GUI