UNPKG

489 BPlain TextView Raw
1import noScroll from 'no-scroll';
2import modalManager from './modalManager';
3
4export const isBrowser = typeof window !== 'undefined';
5
6export const blockNoScroll = () => {
7 noScroll.on();
8};
9
10export const unblockNoScroll = () => {
11 // Restore the scroll only if there is no modal on the screen
12 // We filter the modals that are not affecting the scroll
13 const modals = modalManager.modals().filter((modal) => modal.blockScroll);
14 if (modals.length === 0) {
15 noScroll.off();
16 }
17};