Skip to content

Commit

Permalink
修复sidebar弹出后,背景主体可以滚动的bug (#752)
Browse files Browse the repository at this point in the history
* 修复sidebar弹出后,背景主体可以滚动的bug

* 支持body不滚动,状态复原

* 支持body不滚动,状态复原
  • Loading branch information
jennyliang220 authored and wupengFEX committed Aug 7, 2017
1 parent 6915ea2 commit 9fd8d32
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
3 changes: 2 additions & 1 deletion mip-sidebar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</li>
<li> Nav item 5</li>
<li> Nav item 6</li>
</ul>
</ul>
</mip-sidebar>
```

Expand Down Expand Up @@ -101,6 +101,7 @@
</li>
<li> Nav item 5</li>
<li> Nav item 6</li>
</ul>
</mip-sidebar>
```

Expand Down
16 changes: 8 additions & 8 deletions mip-sidebar/mip-sidebar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file 侧边栏组件
*
* @author [email protected]
* @author [email protected], liangjiaying
* @version 1.0
* @copyright 2016 Baidu.com, Inc. All Rights Reserved
*/
Expand Down Expand Up @@ -29,11 +29,13 @@ define(function (require) {
return;
}

// pageScroll_.call(self);

util.css(self.element, {display: 'block'});
openMask.call(self);


self.bodyOverflow = getComputedStyle(document.body).overflow;
document.body.style.overflow = "hidden";

// 动画效果
var openTimer = setTimeout(function () {

Expand All @@ -60,6 +62,8 @@ define(function (require) {

closeMask.call(self);

document.body.style.overflow = self.bodyOverflow;

// 动画效果
var closeTimer = setTimeout(function () {

Expand Down Expand Up @@ -96,11 +100,7 @@ define(function (require) {
}

self.maskElement.setAttribute('on', 'tap:' + self.id + '.close');
//侧边栏调出来后页面主体部分禁止滚动
self.maskElement.addEventListener('touchmove', function(e) {
e.preventDefault();
e.stopPropagation();
},false);

// 样式设置
util.css(self.maskElement, {display: 'block'});

Expand Down
17 changes: 11 additions & 6 deletions mip-sidebar/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{
"name": "mip-sidebar",
"version": "1.1.4",
"author": {
"name": "wangpei07",
"email": "[email protected]",
"url": "https://www.mipengine.org"
},
"version": "1.1.5",
"contributers": [
{
"name": "wangpei07",
"email": "[email protected]",
"url": "https://www.mipengine.org"
},{
"name": "Jenny_L",
"email": "[email protected]"
}
],
"engines": {
"mip": ">=1.1.0"
}
Expand Down

1 comment on commit 9fd8d32

@zhao-ping
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问这个bug修复以后,用法和原来没有区别吗?我的网页上,侧边栏弹出后,主体页面仍然会滚动。

Please sign in to comment.