如何在激活灯箱插件时禁用鼠标滚轮的背景滚动

How to disable background scrolling with mouse wheel while a lightbox plugin is activated?

本文关键字:鼠标 滚动 背景 激活 插件      更新时间:2023-09-26

我正在开发一个水平滚动网站。在它上面,我正在使用鼠标滚轮.js插件(允许使用鼠标滚轮水平滚动)和 magnific 弹出窗口插件。

当有人通过单击照片激活 magnific 弹出窗口插件时,它会打开照片,因为它应该如此,并且背景滚动条被禁用。

但是,由于我使用的是鼠标滚轮.js,背景仍然可以使用鼠标滚轮滚动。

如何仅在 magnific 弹出窗口显示照片时才禁用背景滚动?

我也有类似的问题。这个决定在一定程度上帮助了我。

$('#open_button').magnificPopup({
    type: 'inline',          // Custom settings, never mind
    closeBtnInside: false,   // Custom settings, never mind
    fixedContentPos: false,  // Custom settings, never mind
    fixedBgPos: true,        // Custom settings, never mind
    callbacks: {
        open: function() {                        // When you open the
            $('body').css('overflow', 'hidden');  // window, the element
        },                                        // "body" is used "overflow: hidden".
        close: function() {                       // When the window
            $('body').css('overflow', '');        // is closed, the 
        },                                        // "overflow" gets the initial value.
    }
});
fixedContentPos: true,
overflowY: 'hidden',

这应该有效!