update util
parent
da0f17d1b6
commit
154e24687c
|
@ -0,0 +1,20 @@
|
|||
import getScrollBarSize from './getScrollBarSize';
|
||||
|
||||
export default (close) => {
|
||||
const bodyIsOverflowing = document.body.scrollHeight >
|
||||
(window.innerHeight || document.documentElement.clientHeight) &&
|
||||
window.innerWidth > document.body.offsetWidth;
|
||||
if (!bodyIsOverflowing) {
|
||||
return;
|
||||
}
|
||||
if (close) {
|
||||
document.body.style.position = '';
|
||||
document.body.style.width = '';
|
||||
return;
|
||||
}
|
||||
const scrollBarSize = getScrollBarSize();
|
||||
if (scrollBarSize) {
|
||||
document.body.style.position = 'relative';
|
||||
document.body.style.width = `calc(100% - ${scrollBarSize}px)`;
|
||||
}
|
||||
};
|
|
@ -1,9 +1,42 @@
|
|||
import warning from 'warning';
|
||||
/* eslint-disable no-console */
|
||||
let warned = {};
|
||||
|
||||
const warned = {};
|
||||
export default (valid, message) => {
|
||||
export function warning(valid, message) {
|
||||
// Support uglify
|
||||
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
||||
console.error(`Warning: ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function note(valid, message) {
|
||||
// Support uglify
|
||||
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
||||
console.warn(`Note: ${message}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function resetWarned() {
|
||||
warned = {};
|
||||
}
|
||||
|
||||
export function call(
|
||||
method,
|
||||
valid,
|
||||
message,
|
||||
) {
|
||||
if (!valid && !warned[message]) {
|
||||
warning(false, message);
|
||||
method(false, message);
|
||||
warned[message] = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function warningOnce(valid, message) {
|
||||
call(warning, valid, message);
|
||||
}
|
||||
|
||||
export function noteOnce(valid, message) {
|
||||
call(note, valid, message);
|
||||
}
|
||||
|
||||
export default warningOnce;
|
||||
/* eslint-enable */
|
||||
|
|
Loading…
Reference in New Issue