diff --git a/src/styles.js b/src/styles.js index 792ef01..4e5c57d 100644 --- a/src/styles.js +++ b/src/styles.js @@ -1,4 +1,6 @@ -import { StyleSheet } from 'react-native'; +import { I18nManager, StyleSheet } from 'react-native'; + +export const HORIZONTAL_DIRECTION = I18nManager.isRTL ? 'right' : 'left'; const styles = StyleSheet.create({ container: { @@ -12,6 +14,7 @@ const styles = StyleSheet.create({ }, background: { ...StyleSheet.absoluteFillObject, + ...(I18nManager.isRTL ? { flexDirection: 'row-reverse' } : {}), }, tooltip: { backgroundColor: 'transparent', @@ -73,7 +76,8 @@ const arrowPlacementStyles = ({ } return { - left: anchorPoint.x - tooltipOrigin.x - (width / 2 - marginLeft), + [HORIZONTAL_DIRECTION]: + anchorPoint.x - tooltipOrigin.x - (width / 2 - marginLeft), top: anchorPoint.y - tooltipOrigin.y - (height / 2 - marginTop), width, height, diff --git a/src/tooltip.js b/src/tooltip.js index 3098692..99c958b 100644 --- a/src/tooltip.js +++ b/src/tooltip.js @@ -20,7 +20,7 @@ import { computeLeftGeometry, computeRightGeometry, } from './geom'; -import styleGenerator from './styles'; +import styleGenerator, { HORIZONTAL_DIRECTION } from './styles'; import TooltipChildrenContext from './tooltip-children.context'; export { TooltipChildrenContext }; @@ -384,7 +384,7 @@ class Tooltip extends Component { height, width, top: y, - left: x, + [HORIZONTAL_DIRECTION]: x, alignItems: 'center', justifyContent: 'center', },