react-native-safe-area
Advanced tools
Comparing version
@@ -12,8 +12,16 @@ // @flow | ||
| 'right' | ||
| 'topLeft' | ||
| 'topRight' | ||
| 'bottomLeft' | ||
| 'bottomRight' | ||
| 'topLeft' // DEPRECATED | ||
| 'topAndLeft' | ||
| 'topRight' // DEPRECATED | ||
| 'topAndRight' | ||
| 'bottomLeft' // DEPRECATED | ||
| 'bottomAndLeft' | ||
| 'bottomRight' // DEPRECATED | ||
| 'bottomAndRight' | ||
| 'vertical' | ||
| 'horizontal' | ||
| 'verticalAndLeft' | ||
| 'verticalAndRight' | ||
| 'horizontalAndTop' | ||
| 'horizontalAndBottom' | ||
| 'all' | ||
@@ -32,29 +40,51 @@ ; | ||
): React.ComponentType<any> { | ||
let _direction = direction | ||
const match = _direction.match(/^(top|bottom)(Left|Right)$/) | ||
if (match) { | ||
_direction = `${match[1]}And${match[2]}` | ||
// eslint-disable-next-line | ||
console.warn(`'${direction}' is deprecated. Use '${_direction}' instead.`) | ||
} | ||
const applysToTop = ( | ||
direction === 'top' || | ||
direction === 'topLeft' || | ||
direction === 'topRight' || | ||
direction === 'vertical' || | ||
direction === 'all' | ||
_direction === 'top' || | ||
_direction === 'topAndLeft' || | ||
_direction === 'topAndRight' || | ||
_direction === 'vertical' || | ||
_direction === 'verticalAndLeft' || | ||
_direction === 'verticalAndRight' || | ||
_direction === 'horizontalAndTop' || | ||
_direction === 'all' | ||
) | ||
const applysToBottom = ( | ||
direction === 'bottom' || | ||
direction === 'bottomLeft' || | ||
direction === 'bottomRight' || | ||
direction === 'vertical' || | ||
direction === 'all' | ||
_direction === 'bottom' || | ||
_direction === 'bottomAndLeft' || | ||
_direction === 'bottomAndRight' || | ||
_direction === 'vertical' || | ||
_direction === 'verticalAndLeft' || | ||
_direction === 'verticalAndRight' || | ||
_direction === 'horizontalAndBottom' || | ||
_direction === 'all' | ||
) | ||
const applysToLeft = ( | ||
direction === 'left' || | ||
direction === 'topLeft' || | ||
direction === 'bottomLeft' || | ||
direction === 'horizontal' || | ||
direction === 'all' | ||
_direction === 'left' || | ||
_direction === 'topAndLeft' || | ||
_direction === 'bottomAndLeft' || | ||
_direction === 'horizontal' || | ||
_direction === 'horizontalAndTop' || | ||
_direction === 'horizontalAndBottom' || | ||
_direction === 'verticalAndLeft' || | ||
_direction === 'all' | ||
) | ||
const applysToRight = ( | ||
direction === 'right' || | ||
direction === 'topRight' || | ||
direction === 'bottomRight' || | ||
direction === 'horizontal' || | ||
direction === 'all' | ||
_direction === 'right' || | ||
_direction === 'topAndRight' || | ||
_direction === 'bottomAndRight' || | ||
_direction === 'horizontal' || | ||
_direction === 'horizontalAndTop' || | ||
_direction === 'horizontalAndBottom' || | ||
_direction === 'verticalAndRight' || | ||
_direction === 'all' | ||
) | ||
@@ -112,5 +142,6 @@ | ||
if (scrollView && scrollView._scrollAnimatedValue) { | ||
scrollView._scrollAnimatedValue.setOffset(injected.contentInset.top); | ||
scrollView._scrollAnimatedValue.setOffset(injected.contentInset.top) | ||
} | ||
} | ||
injected.contentOffset.y = (contentOffset.y || 0) - top | ||
} | ||
@@ -120,3 +151,2 @@ if (applysToBottom) { | ||
} | ||
injected.contentOffset.y = (contentOffset.y || 0) - top | ||
} | ||
@@ -123,0 +153,0 @@ if (applysToLeft || applysToRight) { |
{ | ||
"name": "react-native-safe-area", | ||
"version": "0.4.4", | ||
"version": "0.5.0", | ||
"description": "React Native module to get Safe Area Insets for iOS 11 or later", | ||
@@ -30,3 +30,3 @@ "main": "lib/index", | ||
"babel-preset-flow": "^6.23.0", | ||
"babel-preset-react-native": "^4.0.0", | ||
"babel-preset-react-native": "^5.0.2", | ||
"eslint": "^4.6.1", | ||
@@ -36,5 +36,5 @@ "eslint-plugin-flowtype": "^2.38.0", | ||
"flow-bin": "^0.63.1", | ||
"react": "^16.2.0", | ||
"react-native": "^0.52.0" | ||
"react": "^16.3.1", | ||
"react-native": "^0.56.0" | ||
} | ||
} |
@@ -60,4 +60,12 @@ # react-native-safe-area | ||
- `right` - Apply to right. | ||
- `topAndLeft` - `top` + `left`. | ||
- `topAndRight` - `top` + `right`. | ||
- `bottomAndLeft` - `bottom` + `left`. | ||
- `bottomAndRight` - `bottom` + `right`. | ||
- `horizontal` - `left` + `right`. | ||
- `horizontalAndTop` - `horizontal` + `top`. | ||
- `horizontalAndBottom` - `horizontal` + `bottom`. | ||
- `vertical` - `top` + `bottom`. | ||
- `verticalAndLeft` - `vertical` + `left`. | ||
- `verticalAndRight` - `vertical` + `right`. | ||
- `all` - `horizontal` + `vertical`. (Default) | ||
@@ -64,0 +72,0 @@ |
61416
1.95%292
10.19%168
5%20
-4.76%