[英]How to disable background scrolling with mouse wheel while a lightbox plugin is activated?
我在一個水平滾動的網站上工作。 在上面,我使用了 mousewheel.js 插件(允許使用鼠標滾輪水平滾動)和 magnific-popup 插件。
當有人通過單擊照片激活 magnific-popup 插件時,它會按原樣打開照片,並且禁用背景滾動條。
但是,當我使用 mousewheel.js 時,背景仍然可以用鼠標滾輪滾動。
僅當 magnific-popup 顯示照片時,如何才能禁用背景滾動?
我有一個類似的問題。 這個決定對我有所幫助。
$('#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',
這應該工作!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.