const scrollLockClassName = "critical-editor-scroll-locked";
let scrollLockCount = 0;

export function lockBackgroundScroll() {
    scrollLockCount++;
    if (scrollLockCount !== 1) {
        return;
    }

    document.documentElement.classList.add(scrollLockClassName);
    document.body.classList.add(scrollLockClassName);
}

export function unlockBackgroundScroll() {
    if (scrollLockCount === 0) {
        return;
    }

    scrollLockCount--;
    if (scrollLockCount !== 0) {
        return;
    }

    document.documentElement.classList.remove(scrollLockClassName);
    document.body.classList.remove(scrollLockClassName);
}
