Page is scollable behind lightbox when I want scrolling disabled.

As the title says I have a lightbox pop up. However the page content can still be scrolled through without closing the lightbox. Is there a way to disable page scrolling while a lightbox is open? thanks.

image

Drop this code into Custom code under Settings.

<script>

    //Desktop
    scrollTop =
        window.pageYOffset ||
        document.documentElement.scrollTop;
    scrollLeft =
        window.pageXOffset ||
        document.documentElement.scrollLeft;

        // if any scroll is attempted,
        // set this to the previous value
        window.onscroll = function () {
            window.scrollTo(scrollLeft, scrollTop);
            // console.log('scroll')
        };

    //Mobile
    function preventBehavior(e) {
        e.preventDefault(); 
        // console.log('touchmove')
    };

    document.addEventListener("touchmove", preventBehavior, {passive: false});

</script>