@mpxjs/webpack-plugin 2.10.4-beta.3 → 2.10.4-beta.4
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { useContext, useEffect
|
|
1
|
+
import React, { useContext, useEffect } from 'react';
|
|
2
2
|
import { Keyboard, View } from 'react-native';
|
|
3
3
|
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated';
|
|
4
|
-
import { Gesture } from 'react-native-gesture-handler';
|
|
5
4
|
import { KeyboardAvoidContext } from './context';
|
|
6
5
|
import { isIOS } from './utils';
|
|
7
6
|
const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
@@ -10,20 +9,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
10
9
|
const offset = useSharedValue(0);
|
|
11
10
|
const basic = useSharedValue('auto');
|
|
12
11
|
const keyboardAvoid = useContext(KeyboardAvoidContext);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return Gesture.Tap()
|
|
18
|
-
.onEnd(() => {
|
|
19
|
-
dismiss();
|
|
20
|
-
}).runOnJS(true);
|
|
21
|
-
}, []);
|
|
22
|
-
const animatedStyle = useAnimatedStyle(() => {
|
|
23
|
-
return Object.assign({
|
|
24
|
-
transform: [{ translateY: -offset.value }]
|
|
25
|
-
}, isIOS ? {} : { flexBasis: basic.value });
|
|
26
|
-
});
|
|
12
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
13
|
+
transform: [{ translateY: -offset.value }],
|
|
14
|
+
flexBasis: basic.value
|
|
15
|
+
}));
|
|
27
16
|
const resetKeyboard = () => {
|
|
28
17
|
if (keyboardAvoid?.current) {
|
|
29
18
|
keyboardAvoid.current = null;
|
|
@@ -31,6 +20,9 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
31
20
|
offset.value = withTiming(0, { duration, easing });
|
|
32
21
|
basic.value = 'auto';
|
|
33
22
|
};
|
|
23
|
+
const onTouchEnd = () => {
|
|
24
|
+
Keyboard.isVisible() && Keyboard.dismiss();
|
|
25
|
+
};
|
|
34
26
|
useEffect(() => {
|
|
35
27
|
let subscriptions = [];
|
|
36
28
|
if (isIOS) {
|
|
@@ -46,7 +38,12 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
46
38
|
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
|
|
47
39
|
const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
|
|
48
40
|
const value = aboveOffset > 0 ? belowValue : aboveValue;
|
|
49
|
-
offset.value = withTiming(value, { duration, easing })
|
|
41
|
+
offset.value = withTiming(value, { duration, easing }, (finished) => {
|
|
42
|
+
if (finished) {
|
|
43
|
+
// Set flexBasic after animation to trigger re-layout and reset layout information
|
|
44
|
+
basic.value = '99.99%';
|
|
45
|
+
}
|
|
46
|
+
});
|
|
50
47
|
});
|
|
51
48
|
});
|
|
52
49
|
}),
|
|
@@ -68,11 +65,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
68
65
|
const value = aboveOffset > 0 ? belowValue : aboveValue;
|
|
69
66
|
offset.value = withTiming(value, { duration, easing }, (finished) => {
|
|
70
67
|
if (finished) {
|
|
71
|
-
|
|
72
|
-
* In the Android environment, the layout information is not synchronized after the animation,
|
|
73
|
-
* which results in the inability to correctly trigger element events.
|
|
74
|
-
* Here, we utilize flexBasic to proactively trigger a re-layout
|
|
75
|
-
*/
|
|
68
|
+
// Set flexBasic after animation to trigger re-layout and reset layout information
|
|
76
69
|
basic.value = '99.99%';
|
|
77
70
|
}
|
|
78
71
|
});
|
|
@@ -85,18 +78,14 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
|
|
|
85
78
|
subscriptions.forEach(subscription => subscription.remove());
|
|
86
79
|
};
|
|
87
80
|
}, [keyboardAvoid]);
|
|
88
|
-
return (
|
|
89
|
-
// <GestureDetector gesture={gesture}>
|
|
90
|
-
<View style={style}>
|
|
81
|
+
return (<View style={style} onTouchEnd={onTouchEnd}>
|
|
91
82
|
<Animated.View style={[
|
|
92
83
|
contentContainerStyle,
|
|
93
84
|
animatedStyle
|
|
94
85
|
]}>
|
|
95
86
|
{children}
|
|
96
87
|
</Animated.View>
|
|
97
|
-
</View>
|
|
98
|
-
// </GestureDetector>
|
|
99
|
-
);
|
|
88
|
+
</View>);
|
|
100
89
|
};
|
|
101
90
|
KeyboardAvoidingView.displayName = 'MpxKeyboardAvoidingView';
|
|
102
91
|
export default KeyboardAvoidingView;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React, { ReactNode, useContext, useEffect
|
|
2
|
-
import { DimensionValue, EmitterSubscription, Keyboard,
|
|
3
|
-
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing
|
|
4
|
-
import { GestureDetector, Gesture } from 'react-native-gesture-handler'
|
|
1
|
+
import React, { ReactNode, useContext, useEffect } from 'react'
|
|
2
|
+
import { DimensionValue, EmitterSubscription, Keyboard, View, ViewStyle } from 'react-native'
|
|
3
|
+
import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated'
|
|
5
4
|
import { KeyboardAvoidContext } from './context'
|
|
6
5
|
import { isIOS } from './utils'
|
|
7
6
|
|
|
@@ -19,25 +18,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
19
18
|
const basic = useSharedValue('auto')
|
|
20
19
|
const keyboardAvoid = useContext(KeyboardAvoidContext)
|
|
21
20
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const gesture = useMemo(() => {
|
|
27
|
-
return Gesture.Tap()
|
|
28
|
-
.onEnd(() => {
|
|
29
|
-
dismiss()
|
|
30
|
-
}).runOnJS(true)
|
|
31
|
-
}, [])
|
|
32
|
-
|
|
33
|
-
const animatedStyle = useAnimatedStyle(() => {
|
|
34
|
-
return Object.assign(
|
|
35
|
-
{
|
|
36
|
-
transform: [{ translateY: -offset.value }]
|
|
37
|
-
},
|
|
38
|
-
isIOS ? {} : { flexBasis: basic.value as DimensionValue }
|
|
39
|
-
)
|
|
40
|
-
})
|
|
21
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
22
|
+
transform: [{ translateY: -offset.value }],
|
|
23
|
+
flexBasis: basic.value as DimensionValue
|
|
24
|
+
}))
|
|
41
25
|
|
|
42
26
|
const resetKeyboard = () => {
|
|
43
27
|
if (keyboardAvoid?.current) {
|
|
@@ -47,6 +31,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
47
31
|
basic.value = 'auto'
|
|
48
32
|
}
|
|
49
33
|
|
|
34
|
+
const onTouchEnd = () => {
|
|
35
|
+
Keyboard.isVisible() && Keyboard.dismiss()
|
|
36
|
+
}
|
|
37
|
+
|
|
50
38
|
useEffect(() => {
|
|
51
39
|
let subscriptions: EmitterSubscription[] = []
|
|
52
40
|
|
|
@@ -62,7 +50,12 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
62
50
|
const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing
|
|
63
51
|
const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing)
|
|
64
52
|
const value = aboveOffset > 0 ? belowValue : aboveValue
|
|
65
|
-
offset.value = withTiming(value, { duration, easing })
|
|
53
|
+
offset.value = withTiming(value, { duration, easing }, (finished) => {
|
|
54
|
+
if (finished) {
|
|
55
|
+
// Set flexBasic after animation to trigger re-layout and reset layout information
|
|
56
|
+
basic.value = '99.99%'
|
|
57
|
+
}
|
|
58
|
+
})
|
|
66
59
|
})
|
|
67
60
|
})
|
|
68
61
|
}),
|
|
@@ -82,11 +75,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
82
75
|
const value = aboveOffset > 0 ? belowValue : aboveValue
|
|
83
76
|
offset.value = withTiming(value, { duration, easing }, (finished) => {
|
|
84
77
|
if (finished) {
|
|
85
|
-
|
|
86
|
-
* In the Android environment, the layout information is not synchronized after the animation,
|
|
87
|
-
* which results in the inability to correctly trigger element events.
|
|
88
|
-
* Here, we utilize flexBasic to proactively trigger a re-layout
|
|
89
|
-
*/
|
|
78
|
+
// Set flexBasic after animation to trigger re-layout and reset layout information
|
|
90
79
|
basic.value = '99.99%'
|
|
91
80
|
}
|
|
92
81
|
})
|
|
@@ -102,8 +91,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
102
91
|
}, [keyboardAvoid])
|
|
103
92
|
|
|
104
93
|
return (
|
|
105
|
-
|
|
106
|
-
<View style={style}>
|
|
94
|
+
<View style={style} onTouchEnd={onTouchEnd}>
|
|
107
95
|
<Animated.View
|
|
108
96
|
style={[
|
|
109
97
|
contentContainerStyle,
|
|
@@ -113,7 +101,6 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
|
|
|
113
101
|
{children}
|
|
114
102
|
</Animated.View>
|
|
115
103
|
</View>
|
|
116
|
-
// </GestureDetector>
|
|
117
104
|
)
|
|
118
105
|
}
|
|
119
106
|
|