|
|
@@ -2,7 +2,6 @@
|
|
2
|
2
|
|
|
3
|
3
|
import React from 'react';
|
|
4
|
4
|
import {
|
|
5
|
|
- Dimensions,
|
|
6
|
5
|
TouchableHighlight,
|
|
7
|
6
|
TouchableWithoutFeedback,
|
|
8
|
7
|
View
|
|
|
@@ -39,41 +38,29 @@ export default class Container extends AbstractContainer {
|
|
39
|
38
|
// visible
|
|
40
|
39
|
|
|
41
|
40
|
// The following property is responsible to hide/show this Container by
|
|
42
|
|
- // moving it out of site of the screen boundaries. An attempt to use the
|
|
43
|
|
- // opacity property was made in order to eventually implement a
|
|
44
|
|
- // fadeIn/fadeOut animation, however a known React Native problem was
|
|
45
|
|
- // discovered, which allows the view to still capture touch events even
|
|
46
|
|
- // if hidden.
|
|
47
|
|
- let visibilityStyle;
|
|
|
41
|
+ // setting its size to 0. This will make the component not visible, but
|
|
|
42
|
+ // it won't be destroyed, all its state is preserved. This is
|
|
|
43
|
+ // intentional.
|
|
|
44
|
+ // TODO: replace with display: 'none', supported in RN >= 0.43.
|
|
|
45
|
+ const hidden = visible === false; // true / undefined
|
|
48
|
46
|
|
|
49
|
|
- if (typeof visible !== 'undefined' && !visible) {
|
|
50
|
|
- const windowDimensions = Dimensions.get('window');
|
|
51
|
|
-
|
|
52
|
|
- visibilityStyle = {
|
|
53
|
|
- bottom: -windowDimensions.height,
|
|
54
|
|
- right: -windowDimensions.width
|
|
55
|
|
- };
|
|
56
|
|
- }
|
|
57
|
|
-
|
|
58
|
|
- const renderParent = touchFeedback || onClick;
|
|
59
|
|
-
|
|
60
|
|
- if (!renderParent && visibilityStyle) {
|
|
|
47
|
+ if (hidden) {
|
|
61
|
48
|
style = {
|
|
62
|
49
|
...style,
|
|
63
|
|
- ...visibilityStyle
|
|
|
50
|
+ height: 0,
|
|
|
51
|
+ width: 0
|
|
64
|
52
|
};
|
|
65
|
53
|
}
|
|
66
|
54
|
|
|
67
|
55
|
// eslint-disable-next-line object-property-newline
|
|
68
|
56
|
let component = super._render(View, { ...props, style });
|
|
69
|
57
|
|
|
70
|
|
- if (renderParent) {
|
|
|
58
|
+ if (!hidden && (touchFeedback || onClick)) {
|
|
71
|
59
|
const parentType
|
|
72
|
60
|
= touchFeedback ? TouchableHighlight : TouchableWithoutFeedback;
|
|
73
|
61
|
const parentProps = {};
|
|
74
|
62
|
|
|
75
|
63
|
onClick && (parentProps.onPress = onClick);
|
|
76
|
|
- visibilityStyle && (parentProps.style = visibilityStyle);
|
|
77
|
64
|
|
|
78
|
65
|
component = React.createElement(parentType, parentProps, component);
|
|
79
|
66
|
}
|