File tree Expand file tree Collapse file tree 2 files changed +58
-5
lines changed Expand file tree Collapse file tree 2 files changed +58
-5
lines changed Original file line number Diff line number Diff line change
1
+ import getScrollBarSize from './getScrollBarSize' ;
2
+
3
+ export default ( close ) => {
4
+ const bodyIsOverflowing = document . body . scrollHeight >
5
+ ( window . innerHeight || document . documentElement . clientHeight ) &&
6
+ window . innerWidth > document . body . offsetWidth ;
7
+ if ( ! bodyIsOverflowing ) {
8
+ return ;
9
+ }
10
+ if ( close ) {
11
+ document . body . style . position = '' ;
12
+ document . body . style . width = '' ;
13
+ return ;
14
+ }
15
+ const scrollBarSize = getScrollBarSize ( ) ;
16
+ if ( scrollBarSize ) {
17
+ document . body . style . position = 'relative' ;
18
+ document . body . style . width = `calc(100% - ${ scrollBarSize } px)` ;
19
+ }
20
+ } ;
Original file line number Diff line number Diff line change 1
- import warning from 'warning' ;
1
+ /* eslint-disable no-console */
2
+ let warned = { } ;
2
3
3
- const warned = { } ;
4
- export default ( valid , message ) => {
4
+ export function warning ( valid , message ) {
5
+ // Support uglify
6
+ if ( process . env . NODE_ENV !== 'production' && ! valid && console !== undefined ) {
7
+ console . error ( `Warning: ${ message } ` ) ;
8
+ }
9
+ }
10
+
11
+ export function note ( valid , message ) {
12
+ // Support uglify
13
+ if ( process . env . NODE_ENV !== 'production' && ! valid && console !== undefined ) {
14
+ console . warn ( `Note: ${ message } ` ) ;
15
+ }
16
+ }
17
+
18
+ export function resetWarned ( ) {
19
+ warned = { } ;
20
+ }
21
+
22
+ export function call (
23
+ method ,
24
+ valid ,
25
+ message ,
26
+ ) {
5
27
if ( ! valid && ! warned [ message ] ) {
6
- warning ( false , message ) ;
28
+ method ( false , message ) ;
7
29
warned [ message ] = true ;
8
30
}
9
- } ;
31
+ }
32
+
33
+ export function warningOnce ( valid , message ) {
34
+ call ( warning , valid , message ) ;
35
+ }
36
+
37
+ export function noteOnce ( valid , message ) {
38
+ call ( note , valid , message ) ;
39
+ }
40
+
41
+ export default warningOnce ;
42
+ /* eslint-enable */
You can’t perform that action at this time.
0 commit comments