Skip to content

Commit

Permalink
fix: 修复滚动穿透的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanfei.gyf committed Jul 3, 2019
1 parent 9760e83 commit 6098940
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import IDialogPropTypes from './IDialogPropTypes';
function noop() {
}

function move(e) {
e.preventDefault();
}

export default class Dialog extends React.Component<IDialogPropTypes, any> {
static defaultProps = {
afterClose: noop,
Expand All @@ -24,11 +28,18 @@ export default class Dialog extends React.Component<IDialogPropTypes, any> {
footerRef: any;
wrapRef: any;

componentDidMount() {
if (this.wrapRef) {
this.wrapRef.addEventListener('touchmove', move, false);
}
}

componentWillUnmount() {
// fix: react@16 no dismissing animation
document.body.style.overflow = '';
if (this.wrapRef) {
this.wrapRef.style.display = 'none';
this.wrapRef.removeEventListener('touchmove', move, false);
}
}

Expand Down

0 comments on commit 6098940

Please sign in to comment.