[英]How to enable and disable page scroll
My project is horizontal scroll only. 我的项目仅是水平滚动。 Which mean X.
意思是X。
#landscape
is the whole container. #landscape
是整个容器。
At first, I disable the scroll for #landscape
. 首先,我禁用
#landscape
的滚动。
After that when I clicked .close-reveal-modal
a div
fade in. 之后,当我单击
.close-reveal-modal
, div
淡入。
In this div
I still can't scroll $('#landscape')
. 在这个
div
我仍然无法滚动$('#landscape')
。 After that, I want to enable back the scroll for $('#landscape')
after I close this .close-reveal-modal
. 之后,我要在关闭此
.close-reveal-modal
后启用$('#landscape')
滚动。
I tired to put $('#landscape').off
which mean enable it. 我累了把
$('#landscape').off
,这意味着启用它。 But it doesn't work for me. 但这对我不起作用。
$('#landscape').on('scroll touchmove mousewheel', function(e){ // on off means enable and disable
e.preventDefault();
e.stopPropagation();
return false;
})
$('.close-reveal-modal').click(function(){
setTimeout(function(){
$('#second_load').fadeIn(300);
}, 1000);
});
$('#second_load').click(function(){
$('#second_load').fadeOut(300);
$('#landscape').off('scroll touchmove mousewheel', function(e){ // on off means enable and disable
e.preventDefault();
e.stopPropagation();
return false;
})
});
function freeze() {
var top = $("html").scrollTop() ? $("html").scrollTop() : $("body").scrollTop();
var left = $("html").scrollLeft() ? $("html").scrollLeft() : $("body").scrollLeft();
if(window.innerWidth > document.documentElement.clientWidth) {
$("html").css("overflow-y", "scroll");
}
if(window.innerHeight > document.documentElement.clientHeight) {
$("html").css("overflow-x", "scroll");
}
$("html").css({"width": "100%", "height": "100%", "position": "fixed", "top": -top, "left": -left});
}
function unfreeze() {
$("html").css("position", "static");
$("html, body").scrollTop(-parseInt($("html").css("top")));
$("html, body").scrollLeft(-parseInt($("html").css("left")));
$("html").css({"position": "", "width": "", "height": "", "top": "", "left": "", "overflow-y": "", "overflow-x": ""});
}
Source: https://github.com/HubSpot/vex/issues/155 来源: https : //github.com/HubSpot/vex/issues/155
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.