@@ -22,6 +22,7 @@ declare global {
22
22
}
23
23
24
24
import { CustomScrollAction , Options } from './types'
25
+ import getViewport from './viewport'
25
26
26
27
// @TODO better shadowdom test, 11 = document fragment
27
28
const isElement = el =>
@@ -49,6 +50,7 @@ const canOverflow = (
49
50
}
50
51
51
52
const isScrollable = ( el , skipOverflowHiddenElements : boolean ) =>
53
+ el === getViewport ( ) ||
52
54
( hasScrollableSpace ( el , 'Y' ) &&
53
55
canOverflow ( el , 'Y' , skipOverflowHiddenElements ) ) ||
54
56
( hasScrollableSpace ( el , 'X' ) &&
@@ -218,7 +220,6 @@ export default (
218
220
}
219
221
220
222
const targetRect = target . getBoundingClientRect ( )
221
- const viewport = document . scrollingElement || document . documentElement
222
223
223
224
// Collect all the scrolling boxes, as defined in the spec: https://drafts.csswg.org/cssom-view/#scrolling-box
224
225
const frames : Element [ ] = [ ]
@@ -228,10 +229,7 @@ export default (
228
229
isElement ( ( parent = target . parentNode || target . host ) ) &&
229
230
checkBoundary ( target )
230
231
) {
231
- if (
232
- isScrollable ( parent , skipOverflowHiddenElements ) ||
233
- parent === viewport
234
- ) {
232
+ if ( isScrollable ( parent , skipOverflowHiddenElements ) ) {
235
233
frames . push ( parent )
236
234
}
237
235
@@ -241,6 +239,7 @@ export default (
241
239
242
240
// Workaround Chrome's behavior on clientHeight/clientWidth after introducing visualViewport
243
241
// https://www.quirksmode.org/blog/archives/2016/02/chrome_change_b.html
242
+ const viewport = getViewport ( )
244
243
const viewportWidth = window . visualViewport
245
244
? window . visualViewport . width
246
245
: Math . min ( viewport . clientWidth , window . innerWidth )
0 commit comments