Skip to content

Commit 4b85d63

Browse files
committed
bg use ref
1 parent c620515 commit 4b85d63

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-drawer-menu",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"description": "drawer menu animation component for react",
55
"keywords": [
66
"react",

src/Drawer.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Drawer extends React.PureComponent {
4141

4242
contextDom = null;
4343
contextWrapDom = null;
44+
maskDom = null;
4445

4546
mousePos = null;
4647

@@ -155,7 +156,7 @@ class Drawer extends React.PureComponent {
155156
if ((d.scrollHeight > d.clientHeight || d.scrollWidth > d.clientWidth)) {
156157
doms.push(d);
157158
}
158-
if (d !== this.contextDom) {
159+
if (d !== this.contextDom && d !== this.maskDom) {
159160
setScrollDom(d.parentNode);
160161
}
161162
};
@@ -176,7 +177,7 @@ class Drawer extends React.PureComponent {
176177
removeScroll = (e) => {
177178
const dom = e.target;
178179
const scrollDom = this.getScollDom(dom);
179-
if (dom.className === `${this.props.className}-bg` || this.getIsButtonDom(dom) || !scrollDom) {
180+
if (dom === this.maskDom || this.getIsButtonDom(dom) || !scrollDom) {
180181
e.preventDefault();
181182
e.returnValue = false;
182183
return;
@@ -275,6 +276,9 @@ class Drawer extends React.PureComponent {
275276
<div
276277
className={`${className}-bg`}
277278
onClick={this.onMaskTouchEnd}
279+
ref={(c) => {
280+
this.maskDom = c;
281+
}}
278282
/>
279283
<div
280284
className={`${className}-content-wrapper`}

0 commit comments

Comments
 (0)