1 | import noScroll from 'no-scroll';
|
2 | import modalManager from './modalManager';
|
3 |
|
4 | export const isBrowser = typeof window !== 'undefined';
|
5 |
|
6 | export const blockNoScroll = () => {
|
7 | noScroll.on();
|
8 | };
|
9 |
|
10 | export 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 | };
|