Jquery Scrollify-在模式打开时禁用部分滚动
我在我的网站上使用,在我打开模式后,我很难禁用它的滚动功能。我使用一个标准的onclick操作来打开模态,这样我就可以在其中注入一些东西,但我不确定是什么 这是我的Scrollify初始化:Jquery Scrollify-在模式打开时禁用部分滚动,jquery,css,jquery-scrollify,Jquery,Css,Jquery Scrollify,我在我的网站上使用,在我打开模式后,我很难禁用它的滚动功能。我使用一个标准的onclick操作来打开模态,这样我就可以在其中注入一些东西,但我不确定是什么 这是我的Scrollify初始化: jQuery.scrollify({ section : ".vc_section", sectionName : "section-name", interstitialSection : "", easing: "easeOutExpo", scrollSpeed: 2000, offset : 0,
jQuery.scrollify({
section : ".vc_section",
sectionName : "section-name",
interstitialSection : "",
easing: "easeOutExpo",
scrollSpeed: 2000,
offset : 0,
scrollbars: true,
standardScrollElements: "footer",
setHeights: true,
overflowScroll: true,
updateHash: false,
touchScroll: true,
before:function(i,panels) {
var ref = panels[i].attr("data-section-name");
if(ref === "first") {
jQuery("#hero-container").removeClass("hidden");
}
if(ref === "second") {
jQuery("#hero-container").addClass("hidden");
}
},
after:function() {},
afterResize:function() {},
afterRender:function() {}
});
然后我通过一个简单的onclick函数调用一个modal:
jQuery('.schedule-visit-toggle, .schedule-visit-toggle a').on('click touchstart', function(evt) {
evt.stopPropagation();
evt.preventDefault();
jQuery('#schedule-visit-modal').foundation('open');
});
不管怎样,我都会试着试一试 我猜当模态没有显示时,它有
display:none代码>在其css中
所以你可以做的是:
if ($('#yourModalID').css('display') === 'none') {
scrollify
} else {
do not scrollify
});
可能它不起作用,但值得一试。调用$.scrollify.disable()
在打开模式时禁用scrollify。我在afterRender:function()中添加了此代码。
和附加样式css
.layout-open{
touch-action: none;
}
它工作得很好如果您在您已经尝试过的内容或您已经更新过的问题上发布一些示例代码,会更容易提供帮助。我可以尝试一下,但在切换模式时,您是否需要基本上重新初始化它,作为一个条件语句?可能您可以添加:else($(“#yourModalID”).css('display')!='none'){不要滚动}
->答案已编辑
.layout-open{
touch-action: none;
}