JS - 移动端滚动穿透
var ModalHelper = (function(bodyCls) {
var scrollTop;
return {
//使body不可滚动
afterOpen: function() {
scrollTop = document.scrollingElement.scrollTop;
document.body.classList.add(bodyCls);
document.body.style.top = -scrollTop + 'px';
},
//使body恢复滚动
beforeClose: function() {
document.body.classList.remove(bodyCls);
document.scrollingElement.scrollTop = scrollTop;
}
};
})('modal-open');