@@ -44,6 +44,11 @@ export interface Rect {
44
44
45
45
//
46
46
47
+ const getRect = ( element : HTMLElement ) : Rect => {
48
+ const { offsetWidth, offsetHeight } = element
49
+ return { width : offsetWidth , height : offsetHeight }
50
+ }
51
+
47
52
export const defaultKeyExtractor = ( index : number ) => index
48
53
49
54
export const defaultRangeExtractor = ( range : Range ) => {
@@ -77,7 +82,7 @@ export const observeElementRect = <T extends Element>(
77
82
cb ( { width : Math . round ( width ) , height : Math . round ( height ) } )
78
83
}
79
84
80
- handler ( element . getBoundingClientRect ( ) )
85
+ handler ( getRect ( element as unknown as HTMLElement ) )
81
86
82
87
if ( ! targetWindow . ResizeObserver ) {
83
88
return ( ) => { }
@@ -93,7 +98,7 @@ export const observeElementRect = <T extends Element>(
93
98
return
94
99
}
95
100
}
96
- handler ( element . getBoundingClientRect ( ) )
101
+ handler ( getRect ( element as unknown as HTMLElement ) )
97
102
}
98
103
99
104
instance . options . useAnimationFrameWithResizeObserver
@@ -251,11 +256,10 @@ export const measureElement = <TItemElement extends Element>(
251
256
return size
252
257
}
253
258
}
254
- return Math . round (
255
- element . getBoundingClientRect ( ) [
256
- instance . options . horizontal ? 'width' : 'height'
257
- ] ,
258
- )
259
+
260
+ return ( element as unknown as HTMLElement ) [
261
+ instance . options . horizontal ? 'offsetWidth' : 'offsetHeight'
262
+ ]
259
263
}
260
264
261
265
export const windowScroll = < T extends Window > (
0 commit comments