@@ -106,6 +106,10 @@ class Hint extends BaseComponent {
106
106
* Callback for the background press
107
107
*/
108
108
onBackgroundPress : PropTypes . func ,
109
+ /**
110
+ * The hint container width
111
+ */
112
+ containerWidth : PropTypes . number ,
109
113
/**
110
114
* The hint's test identifier
111
115
*/
@@ -141,6 +145,11 @@ class Hint extends BaseComponent {
141
145
}
142
146
} ;
143
147
148
+ get containerWidth ( ) {
149
+ const { containerWidth} = this . getThemeProps ( ) ;
150
+ return containerWidth || Constants . screenWidth ;
151
+ }
152
+
144
153
get targetLayout ( ) {
145
154
const { onBackgroundPress, targetFrame} = this . props ;
146
155
const { targetLayout, targetLayoutInWindow} = this . state ;
@@ -181,9 +190,9 @@ class Hint extends BaseComponent {
181
190
getTargetPositionOnScreen ( ) {
182
191
const targetMidPosition = this . targetLayout . x + this . targetLayout . width / 2 ;
183
192
184
- if ( targetMidPosition > Constants . screenWidth * ( 2 / 3 ) ) {
193
+ if ( targetMidPosition > this . containerWidth * ( 2 / 3 ) ) {
185
194
return TARGET_POSITIONS . RIGHT ;
186
- } else if ( targetMidPosition < Constants . screenWidth * ( 1 / 3 ) ) {
195
+ } else if ( targetMidPosition < this . containerWidth * ( 1 / 3 ) ) {
187
196
return TARGET_POSITIONS . LEFT ;
188
197
}
189
198
return TARGET_POSITIONS . CENTER ;
@@ -222,7 +231,7 @@ class Hint extends BaseComponent {
222
231
if ( targetPositionOnScreen === TARGET_POSITIONS . LEFT ) {
223
232
paddings . paddingLeft = this . targetLayout . x ;
224
233
} else if ( targetPositionOnScreen === TARGET_POSITIONS . RIGHT ) {
225
- paddings . paddingRight = Constants . screenWidth - this . targetLayout . x - this . targetLayout . width ;
234
+ paddings . paddingRight = this . containerWidth - this . targetLayout . x - this . targetLayout . width ;
226
235
}
227
236
}
228
237
return paddings ;
@@ -243,8 +252,8 @@ class Hint extends BaseComponent {
243
252
244
253
const leftPosition = this . useSideTip ? this . targetLayout . x : this . targetLayout . x + targetMidWidth - tipMidWidth ;
245
254
const rightPosition = this . useSideTip
246
- ? Constants . screenWidth - this . targetLayout . x - this . targetLayout . width
247
- : Constants . screenWidth - this . targetLayout . x - targetMidWidth - tipMidWidth ;
255
+ ? this . containerWidth - this . targetLayout . x - this . targetLayout . width
256
+ : this . containerWidth - this . targetLayout . x - targetMidWidth - tipMidWidth ;
248
257
const targetPositionOnScreen = this . getTargetPositionOnScreen ( ) ;
249
258
250
259
switch ( targetPositionOnScreen ) {
@@ -315,7 +324,7 @@ class Hint extends BaseComponent {
315
324
< AnimatableView
316
325
animation = { shownUp ? AnimatableManager . animations . hintAppearUp : AnimatableManager . animations . hintAppearDown }
317
326
duration = { 200 }
318
- style = { [ { width : Constants . screenWidth } , styles . animatedContainer , this . getHintPosition ( ) , this . getHintPadding ( ) ] }
327
+ style = { [ { width : this . containerWidth } , styles . animatedContainer , this . getHintPosition ( ) , this . getHintPadding ( ) ] }
319
328
pointerEvents = "box-none"
320
329
testID = { testID }
321
330
>
0 commit comments