Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove useless code #161

Merged
merged 3 commits into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"dependencies": {
"@babel/runtime": "^7.10.1",
"classnames": "^2.2.6",
"omit.js": "^2.0.2",
"rc-util": "^5.6.2"
}
}
15 changes: 4 additions & 11 deletions src/DrawerChild.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as React from 'react';
import classnames from 'classnames';
import getScrollBarSize from 'rc-util/lib/getScrollBarSize';
import KeyCode from 'rc-util/lib/KeyCode';
import * as React from 'react';
import omit from 'omit.js';

import { IDrawerChildProps } from './IDrawerPropTypes';

Expand Down Expand Up @@ -284,9 +285,8 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
};

private toggleScrollingToDrawerAndBody = (right: number) => {
const { getOpenCount, getContainer, showMask, open } = this.props;
const { getContainer, showMask, open } = this.props;
const container = getContainer && getContainer();
const openCount = getOpenCount && getOpenCount();
// 处理 body 滚动
if (container && container.parentNode === document.body && showMask) {
const eventArray = ['touchstart'];
Expand All @@ -300,9 +300,6 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
if (right) {
this.addScrollingEffect(right);
}
if (openCount === 1) {
document.body.style.overflow = 'hidden';
}
document.body.style.touchAction = 'none';
shaodahong marked this conversation as resolved.
Show resolved Hide resolved
// 手机禁滚
domArray.forEach((item, i) => {
Expand All @@ -317,10 +314,6 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
);
});
} else if (this.getCurrentDrawerSome()) {
// 没有弹框的状态下清除 overflow;
if (!openCount) {
document.body.style.overflow = '';
}
document.body.style.touchAction = '';
if (right) {
this.remScrollingEffect(right);
Expand Down Expand Up @@ -524,7 +517,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
});
return (
<div
{...props}
{...omit(props, ['switchScrollingEffect'])}
tabIndex={-1}
className={wrapperClassName}
style={style}
Expand Down
1 change: 1 addition & 0 deletions src/IDrawerPropTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ export interface IDrawerChildProps extends IProps {
getContainer?: () => HTMLElement;
getOpenCount?: () => number;
scrollLocker?: ScrollLocker;
switchScrollingEffect?: () => void;
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/drawer.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ exports[`Drawer render dom 1`] = `
<div>
<div
class="main ant-scrolling-effect"
style="padding-right: 0px; overflow: hidden; overflow-x: hidden; overflow-y: hidden;"
style="overflow: hidden; overflow-x: hidden; overflow-y: hidden;"
>
<div>
<div
Expand Down