php禁止全屏滑动,vue禁止局部滚动/禁止局部滑动事件其他模块化开发框架react/angular禁止局部滑动同理...

stopScroll:function(maskShow){// scrollType为蒙版显隐判断

let bodyWidth = document.body.offsetWidth;

let taskTopOffsetTop = document.getElementById("taskTop").getBoundingClientRect().top*(375/bodyWidth);//loadMore距离顶部的距离

let pageGridOffsetTop = document.getElementById("pageGrid").getBoundingClientRect().top*(375/bodyWidth);//loadMore距离顶部的距离

console.log("taskTopOffsetTop",taskTopOffsetTop);

if(maskShow){

this.scrollTop = document.body.scrollTop*(375/bodyWidth);

console.log("scrollTop",scrollType,this.scrollTop);

//让页面元素位置保持不动

document.getElementById("taskTop").style.position = "fixed";

document.getElementById("taskTop").style.top = taskTopOffsetTop+"px";

document.getElementById("pageGrid").style.position = "fixed";

document.getElementById("pageGrid").style.top = pageGridOffsetTop+"px";

$("html,body").addClass("scrollYHide");//禁止PC滚动

}else{

$("html,body").removeClass("scrollYHide");//解放PC滚动

//恢复页面元素位置

if(!this.$parent.isFixed){

document.getElementById("taskTop").style.position = "relative";

document.getElementById("taskTop").style.top = "auto";

document.getElementById("pageGrid").style.position = "relative";

document.getElementById("pageGrid").style.top = "auto";

console.log("scrollTop",scrollType,this.scrollTop);

document.body.scrollTop = this.scrollTop;

console.log("body",document.body.scrollTop);

}

}mounted:function(){

let onScroll = document.addEventListener("touchmove",function(event){

if(maskShow){//maskShow为蒙版的显隐状态

event.preventDefault();

}

},false);// 监听滚动

}//移动端禁止局部滚动

//PC端禁止局部滚动

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值