Skip to content

Commit

Permalink
chore: remove useless code (#161)
Browse files Browse the repository at this point in the history
* chore: remove useless code fixes ant-design/ant-design#28810 fixes react-component/util#183

* fix ts type

* update snapshots
  • Loading branch information
shaodahong committed Jan 12, 2021
1 parent 7c2d956 commit 90912f5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
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';
// 手机禁滚
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

1 comment on commit 90912f5

@vercel
Copy link

@vercel vercel bot commented on 90912f5 Jan 12, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.