Skip to content

Commit 90912f5

Browse files
authored
chore: remove useless code (#161)
* chore: remove useless code fixes ant-design/ant-design#28810 fixes react-component/util#183 * fix ts type * update snapshots
1 parent 7c2d956 commit 90912f5

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"dependencies": {
7272
"@babel/runtime": "^7.10.1",
7373
"classnames": "^2.2.6",
74+
"omit.js": "^2.0.2",
7475
"rc-util": "^5.6.2"
7576
}
7677
}

src/DrawerChild.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import * as React from 'react';
12
import classnames from 'classnames';
23
import getScrollBarSize from 'rc-util/lib/getScrollBarSize';
34
import KeyCode from 'rc-util/lib/KeyCode';
4-
import * as React from 'react';
5+
import omit from 'omit.js';
56

67
import { IDrawerChildProps } from './IDrawerPropTypes';
78

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

286287
private toggleScrollingToDrawerAndBody = (right: number) => {
287-
const { getOpenCount, getContainer, showMask, open } = this.props;
288+
const { getContainer, showMask, open } = this.props;
288289
const container = getContainer && getContainer();
289-
const openCount = getOpenCount && getOpenCount();
290290
// 处理 body 滚动
291291
if (container && container.parentNode === document.body && showMask) {
292292
const eventArray = ['touchstart'];
@@ -300,9 +300,6 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
300300
if (right) {
301301
this.addScrollingEffect(right);
302302
}
303-
if (openCount === 1) {
304-
document.body.style.overflow = 'hidden';
305-
}
306303
document.body.style.touchAction = 'none';
307304
// 手机禁滚
308305
domArray.forEach((item, i) => {
@@ -317,10 +314,6 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
317314
);
318315
});
319316
} else if (this.getCurrentDrawerSome()) {
320-
// 没有弹框的状态下清除 overflow;
321-
if (!openCount) {
322-
document.body.style.overflow = '';
323-
}
324317
document.body.style.touchAction = '';
325318
if (right) {
326319
this.remScrollingEffect(right);
@@ -524,7 +517,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
524517
});
525518
return (
526519
<div
527-
{...props}
520+
{...omit(props, ['switchScrollingEffect'])}
528521
tabIndex={-1}
529522
className={wrapperClassName}
530523
style={style}

src/IDrawerPropTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ export interface IDrawerChildProps extends IProps {
4646
getContainer?: () => HTMLElement;
4747
getOpenCount?: () => number;
4848
scrollLocker?: ScrollLocker;
49+
switchScrollingEffect?: () => void;
4950
}

tests/__snapshots__/drawer.spec.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ exports[`Drawer render dom 1`] = `
4242
<div>
4343
<div
4444
class="main ant-scrolling-effect"
45-
style="padding-right: 0px; overflow: hidden; overflow-x: hidden; overflow-y: hidden;"
45+
style="overflow: hidden; overflow-x: hidden; overflow-y: hidden;"
4646
>
4747
<div>
4848
<div

0 commit comments

Comments
 (0)