File tree Expand file tree Collapse file tree 2 files changed +30
-9
lines changed Expand file tree Collapse file tree 2 files changed +30
-9
lines changed Original file line number Diff line number Diff line change 1
1
import css from 'dom-helpers/style' ;
2
2
import classes from 'dom-helpers/class' ;
3
3
import getScrollbarSize from 'dom-helpers/util/scrollbarSize' ;
4
- import isWindow from 'dom-helpers/query/isWindow' ;
5
-
6
- function containerClientHeight ( container ) {
7
- let win = isWindow ( container ) ;
8
- return win
9
- ? win . documentElement . clientHeight
10
- : container . clientHeight ;
11
- }
4
+ import isOverflowing from './utils/isOverflowing' ;
12
5
13
6
let findContainer = ( data , modal ) => {
14
7
let idx = - 1 ;
@@ -73,7 +66,7 @@ class ModalManager {
73
66
overflow : 'hidden'
74
67
} ;
75
68
76
- data . overflowing = container . scrollHeight > containerClientHeight ( container ) ;
69
+ data . overflowing = isOverflowing ( container ) ;
77
70
78
71
if ( data . overflowing ) {
79
72
// use computed style, here to get the real padding
Original file line number Diff line number Diff line change
1
+ import isWindow from 'dom-helpers/query/isWindow' ;
2
+ import ownerDocument from 'dom-helpers/ownerDocument' ;
3
+
4
+ function isBody ( node ) {
5
+ return node && node . tagName . toLowerCase ( ) === 'body' ;
6
+ }
7
+
8
+ function bodyIsOverflowing ( node ) {
9
+ let doc = ownerDocument ( node ) ;
10
+ let win = isWindow ( doc ) ;
11
+ let fullWidth = win . innerWidth ;
12
+
13
+ // Support: ie8, no innerWidth
14
+ if ( ! fullWidth ) {
15
+ let documentElementRect = doc . documentElement . getBoundingClientRect ( ) ;
16
+ fullWidth = documentElementRect . right - Math . abs ( documentElementRect . left ) ;
17
+ }
18
+
19
+ return doc . body . clientWidth < fullWidth ;
20
+ }
21
+
22
+ export default function isOverflowing ( container ) {
23
+ let win = isWindow ( container ) ;
24
+
25
+ return win || isBody ( container )
26
+ ? bodyIsOverflowing ( container )
27
+ : container . scrollHeight > container . clientHeight ;
28
+ }
You can’t perform that action at this time.
0 commit comments