File tree 2 files changed +11
-19
lines changed
2 files changed +11
-19
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ export class Helper {
63
63
div . style . height = `${ this . targetSize . height } px` ;
64
64
div . style . width = `${ this . targetSize . width } px` ;
65
65
div . style . position = 'absolute' ;
66
+ div . style . display = 'none' ;
66
67
document . body . insertAdjacentElement ( 'beforeend' , div ) ;
67
68
}
68
69
@@ -212,16 +213,17 @@ export class Helper {
212
213
213
214
targetEl ! . getBoundingClientRect = jest . fn ( ( ) => {
214
215
const top = 0 ,
215
- left = 0 ;
216
+ left = 0 ,
217
+ hiddenSize = targetEl ?. style . display === 'none' ? 0 : null ;
216
218
217
219
return {
218
220
x : left ,
219
221
y : top ,
220
- width : this . targetSize . width ,
221
- height : this . targetSize . height ,
222
+ width : hiddenSize ?? this . targetSize . width ,
223
+ height : hiddenSize ?? this . targetSize . height ,
222
224
top : top ,
223
- right : left + this . targetSize . width ,
224
- bottom : top + this . targetSize . height ,
225
+ right : left + ( hiddenSize ?? this . targetSize . width ) ,
226
+ bottom : top + ( hiddenSize ?? this . targetSize . height ) ,
225
227
left : left ,
226
228
toJSON : ( ) => '{}' ,
227
229
} ;
Original file line number Diff line number Diff line change @@ -24,8 +24,7 @@ const windowSize: SizeData = {
24
24
'bottom center' ,
25
25
'bottom right' ,
26
26
] ,
27
- helper = new Helper ( CollisionHandler . ignore , anchorSize , targetSize ) ,
28
- collisionHandler : ( input : number ) => number = ( input ) => input + 50 ;
27
+ helper = new Helper ( CollisionHandler . ignore , anchorSize , targetSize ) ;
29
28
30
29
helper . setupEnvironment ( windowSize ) ;
31
30
@@ -86,18 +85,9 @@ test('Window scroll adjusts output', () => {
86
85
left : parseInt ( pData . left , 10 ) ,
87
86
top : parseInt ( pData . top , 10 ) ,
88
87
} ) . toStrictEqual ( {
89
- left : helper . getLeft (
90
- targetWindowPosition ,
91
- myPlacement ,
92
- atPlacement ,
93
- collisionHandler ,
94
- ) ,
95
- top : helper . getTop (
96
- targetWindowPosition ,
97
- myPlacement ,
98
- atPlacement ,
99
- collisionHandler ,
100
- ) ,
88
+ left :
89
+ helper . getLeft ( targetWindowPosition , myPlacement , atPlacement ) + 50 ,
90
+ top : helper . getTop ( targetWindowPosition , myPlacement , atPlacement ) + 50 ,
101
91
} ) ;
102
92
103
93
// Reset the window scroll position
You can’t perform that action at this time.
0 commit comments