@mpxjs/webpack-plugin 2.10.14-beta.19 → 2.10.14-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,6 +15,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
15
15
|
// 因此增加状态标记 + clearTimeout + cancelAnimation 来优化
|
|
16
16
|
const isShow = useRef(false);
|
|
17
17
|
const timerRef = useRef(null);
|
|
18
|
+
const keybaordHandleTimerRef = useRef(null);
|
|
18
19
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
19
20
|
// translate/position top可能会导致底部渲染区域缺失(需要 android 配置聚焦时禁用高度缩小),margin-top 会导致 portal 的定位失效,无法顶起 portal
|
|
20
21
|
transform: [{ translateY: -offset.value }],
|
|
@@ -48,12 +49,13 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
48
49
|
};
|
|
49
50
|
useEffect(() => {
|
|
50
51
|
let subscriptions = [];
|
|
52
|
+
// iphone 16 pro & iphone 其它 pro 上长按可能会触发两次 keyboard show 事件,第一次键盘高度错误,第二次正确,因此不能用节流、仅首次生效等操作控制 show 事件
|
|
51
53
|
function keybaordAvoding(evt, ios = false) {
|
|
52
54
|
if (keyboardAvoid?.current?.readyToShow) {
|
|
53
55
|
// 重置标记位
|
|
54
56
|
keyboardAvoid.current.readyToShow = false;
|
|
55
57
|
}
|
|
56
|
-
if (!keyboardAvoid?.current
|
|
58
|
+
if (!keyboardAvoid?.current) {
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
59
61
|
isShow.current = true;
|
|
@@ -98,7 +100,11 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
98
100
|
if (isIOS) {
|
|
99
101
|
subscriptions = [
|
|
100
102
|
Keyboard.addListener('keyboardWillShow', (evt) => {
|
|
101
|
-
|
|
103
|
+
if (keybaordHandleTimerRef.current) {
|
|
104
|
+
clearTimeout(keybaordHandleTimerRef.current);
|
|
105
|
+
}
|
|
106
|
+
// iphone 在input聚焦时长按滑动后会导致 show 事件先于 focus 事件发生,因此等一下,等 focus 先触发拿到 input,避免键盘出现但input没顶上去
|
|
107
|
+
keybaordHandleTimerRef.current = setTimeout(() => keybaordAvoding(evt, true), 32);
|
|
102
108
|
}),
|
|
103
109
|
Keyboard.addListener('keyboardWillHide', resetKeyboard)
|
|
104
110
|
];
|
|
@@ -109,6 +115,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
109
115
|
return () => {
|
|
110
116
|
subscriptions.forEach(subscription => subscription.remove());
|
|
111
117
|
timerRef.current && clearTimeout(timerRef.current);
|
|
118
|
+
keybaordHandleTimerRef.current && clearTimeout(keybaordHandleTimerRef.current);
|
|
112
119
|
};
|
|
113
120
|
}, [keyboardAvoid]);
|
|
114
121
|
return (<View style={style} onTouchEnd={onTouchEnd} onTouchMove={onTouchEnd}>
|
|
@@ -24,6 +24,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
24
24
|
// 因此增加状态标记 + clearTimeout + cancelAnimation 来优化
|
|
25
25
|
const isShow = useRef<boolean>(false)
|
|
26
26
|
const timerRef = useRef<NodeJS.Timeout | null>(null)
|
|
27
|
+
const keybaordHandleTimerRef = useRef<NodeJS.Timeout | null>(null)
|
|
27
28
|
|
|
28
29
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
29
30
|
// translate/position top可能会导致底部渲染区域缺失(需要 android 配置聚焦时禁用高度缩小),margin-top 会导致 portal 的定位失效,无法顶起 portal
|
|
@@ -65,12 +66,14 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
65
66
|
useEffect(() => {
|
|
66
67
|
let subscriptions: EmitterSubscription[] = []
|
|
67
68
|
|
|
69
|
+
// iphone 16 pro & iphone 其它 pro 上长按可能会触发两次 keyboard show 事件,第一次键盘高度错误,第二次正确,因此不能用节流、仅首次生效等操作控制 show 事件
|
|
68
70
|
function keybaordAvoding(evt: any, ios = false) {
|
|
69
71
|
if (keyboardAvoid?.current?.readyToShow) {
|
|
70
72
|
// 重置标记位
|
|
71
73
|
keyboardAvoid.current.readyToShow = false
|
|
72
74
|
}
|
|
73
|
-
|
|
75
|
+
|
|
76
|
+
if (!keyboardAvoid?.current) {
|
|
74
77
|
return
|
|
75
78
|
}
|
|
76
79
|
|
|
@@ -121,7 +124,11 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
121
124
|
if (isIOS) {
|
|
122
125
|
subscriptions = [
|
|
123
126
|
Keyboard.addListener('keyboardWillShow', (evt: any) => {
|
|
124
|
-
|
|
127
|
+
if (keybaordHandleTimerRef.current) {
|
|
128
|
+
clearTimeout(keybaordHandleTimerRef.current)
|
|
129
|
+
}
|
|
130
|
+
// iphone 在input聚焦时长按滑动后会导致 show 事件先于 focus 事件发生,因此等一下,等 focus 先触发拿到 input,避免键盘出现但input没顶上去
|
|
131
|
+
keybaordHandleTimerRef.current = setTimeout(() => keybaordAvoding(evt, true), 32)
|
|
125
132
|
}),
|
|
126
133
|
Keyboard.addListener('keyboardWillHide', resetKeyboard)
|
|
127
134
|
]
|
|
@@ -132,6 +139,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
132
139
|
return () => {
|
|
133
140
|
subscriptions.forEach(subscription => subscription.remove())
|
|
134
141
|
timerRef.current && clearTimeout(timerRef.current)
|
|
142
|
+
keybaordHandleTimerRef.current && clearTimeout(keybaordHandleTimerRef.current)
|
|
135
143
|
}
|
|
136
144
|
}, [keyboardAvoid])
|
|
137
145
|
|