When moving a pop-up layer (called layer), there is a lot of text in the layer that needs scrolling, but the background layer (body) scrolls with the layer scrolling and the user experience is poor. Refer to some information on the Internet, summarize the solution as follows:
. scrollfix{
height:100%;
Overflow:hidden;
position:relative;
}
. Scrollfix body{
height:100%;
Overflow:hidden;
}
Before the pop-up layer:
Prevents the body layer from scrolling down after the content display is not complete problem
$ (' html,body '). Animate ({scrolltop:0}, 100);
$ (' HTML '). addclass (' Scrollfix ');
After the popup layer is closed (typically the layer's shutdown callback):
$ (' HTML '). Removeclass (' Scrollfix ');
There is also a way to disable the background layer Touchmove event
function Showlayer () {
Bgdom.ontouchmove=function (e) {
E.preventdefault && E.preventdefault ();
E.returnvalue=false;
E.stoppropagation && e.stoppropagation ();
return false;
}
}
Or
function Fscrollfix (e) {
E.preventdefault ();
E.stoppropagation ();
}
Bgdom.addeventlistener (' Touchmove ', fscrollfix,false);
function Closelayer ()
{
Bgdom.ontouchmove=function (e) {
E.preventdefault && E.preventdefault ();
E.returnvalue=true;
E.stoppropagation && e.stoppropagation ();
return true;
}
}
Or
Bgdom.removeeventlistener (' Touchmove ', fscrollfix,false);
Bgdom is the background Layer DOM object, this scenario is unsuccessful for the author's experiment
Reference: http://segmentfault.com/q/1010000003089816
Http://www.w3cfuns.com/article-5600528-1-1.html
http://zhangzhaoaaa.iteye.com/blog/2105145
Summary of scrolling penetration of mobile-side pop-up layers