Scrollify - 模式打开时禁用部分滚动
Scrollify - Disable section scrolling when modal is open
我在我的网站上使用 https://projects.lukehaas.me/scrollify/,我在打开模式后无法禁用它的滚动功能。我正在使用标准的 onclick 操作来打开模式,因此我可以在其中注入一些东西,但我不确定是什么。
这是我的 Scrollify 初始化:
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 函数调用模态:
jQuery('.schedule-visit-toggle, .schedule-visit-toggle a').on('click touchstart', function(evt) {
evt.stopPropagation();
evt.preventDefault();
jQuery('#schedule-visit-modal').foundation('open');
});
无论如何我都会尝试一下..
我想当模态未显示时,它的 css 中有 display: none;
。
所以你可以做的是:
if ($('#yourModalID').css('display') === 'none') {
scrollify
} else {
do not scrollify
});
可能行不通,但值得一试..
调用 $.scrollify.disable()
以在模式打开时禁用 Scrollify。
我在 afterRender:function() {}
中添加这段代码
$(".mobile-menu-toggle").on("click",function() {
$("body").toggleClass("layout-open");
if($("body").hasClass('layout-open')){
$.scrollify.disable();
}else{
$.scrollify.enable();
}
});
并添加样式 css
.layout-open{
touch-action: none;
}
它运行良好
我在我的网站上使用 https://projects.lukehaas.me/scrollify/,我在打开模式后无法禁用它的滚动功能。我正在使用标准的 onclick 操作来打开模式,因此我可以在其中注入一些东西,但我不确定是什么。
这是我的 Scrollify 初始化:
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 函数调用模态:
jQuery('.schedule-visit-toggle, .schedule-visit-toggle a').on('click touchstart', function(evt) {
evt.stopPropagation();
evt.preventDefault();
jQuery('#schedule-visit-modal').foundation('open');
});
无论如何我都会尝试一下..
我想当模态未显示时,它的 css 中有 display: none;
。
所以你可以做的是:
if ($('#yourModalID').css('display') === 'none') {
scrollify
} else {
do not scrollify
});
可能行不通,但值得一试..
调用 $.scrollify.disable()
以在模式打开时禁用 Scrollify。
我在 afterRender:function() {}
中添加这段代码$(".mobile-menu-toggle").on("click",function() {
$("body").toggleClass("layout-open");
if($("body").hasClass('layout-open')){
$.scrollify.disable();
}else{
$.scrollify.enable();
}
});
并添加样式 css
.layout-open{
touch-action: none;
}
它运行良好