-
Notifications
You must be signed in to change notification settings - Fork 19
Description
描述 / Description
键盘弹起后手势识别位置不正确,见 demo
复现步骤 / Steps to reproduce
// KebApp.tsx
import * as React from 'react';
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { NavigationContainer } from '@react-navigation/native'
import TransformEvent from './transformEvent';
const Stack = createNativeStackNavigator()
export default function App() {
return (
<Stack.Navigator>
<Stack.Screen name="Home" component={TransformEvent} />
</Stack.Navigator>
);
}
// transformEvent.tsx
import React, { useState } from 'react'
import {
View,
StyleSheet,
TextInput,
Dimensions,
Alert,
TouchableOpacity,
Text,
} from 'react-native'
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window')
export default function TransformEvent() {
const [inputValue, setInputValue] = useState('input测试')
const [popupScale, setPopupScale] = useState(1)
const layerTapClose = () => {
Alert.alert('触发弹层关闭事件')
}
const closePopup = () => {
Alert.alert('触发弹层关闭事件')
setPopupScale(0)
}
// 阻止事件冒泡:layer 内点击不关闭弹窗
const catchTap = (e: any) => {
// Alert.alert('触发内容事件')
e?.stopPropagation?.()
}
return (
<View
style={[styles.bottomPopupLayer, { transform: [{ scale: popupScale }] }]}
onTouchEnd={catchTap}
>
关闭弹窗 (scale 0)
)
}
const styles = StyleSheet.create({
page: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f5f5f5',
},
// bottom-popup-wrapper: 全屏、蓝色、点击关闭
bottomPopupWrapper: {
position: 'absolute',
width: SCREEN_WIDTH,
height: SCREEN_HEIGHT,
bottom: 0,
left: 0,
backgroundColor: 'blue',
},
// bottom-popup-layer: 底部、红色、阻止冒泡
bottomPopupLayer: {
position: 'absolute',
width: '100%',
bottom: 0,
backgroundColor: 'red',
},
closeBtn: {
paddingVertical: 12,
paddingHorizontal: 20,
backgroundColor: '#333',
alignItems: 'center',
},
closeBtnText: {
color: '#fff',
fontSize: 16,
},
pinkBlock: {
backgroundColor: 'pink',
height: 100,
},
inputBlock: {
height: 100,
backgroundColor: '#fff',
padding: 8,
fontSize: 14,
},
})
库版本 / Library version
4.8.1-rc.7
React Native OpenHarmony version
0.77.48
构建类型 / Build type
None
设备 / Device
None
设备版本 / Device model
No response
已悉知 / Acknowledgements
Yes