Skip to content

Commit 16b9121

Browse files
authored
Merge pull request #120 from react-component/refactor-switch-scrolling-effect
refactor: use rc-util Portal switchScrollingEffect
2 parents 9cbfeff + 31484de commit 16b9121

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"dependencies": {
7373
"babel-runtime": "^6.26.0",
7474
"classnames": "^2.2.6",
75-
"rc-util": "^4.11.2",
75+
"rc-util": "^4.16.1",
7676
"react-lifecycles-compat": "^3.0.4"
7777
}
7878
}

src/DrawerChild.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import classnames from 'classnames';
22
import getScrollBarSize from 'rc-util/lib/getScrollBarSize';
33
import KeyCode from 'rc-util/lib/KeyCode';
4-
import switchScrollingEffect from 'rc-util/lib/switchScrollingEffect';
54
import * as React from 'react';
65
import { polyfill } from 'react-lifecycles-compat';
76

@@ -121,7 +120,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
121120
}
122121

123122
public componentWillUnmount() {
124-
const { getOpenCount, open } = this.props;
123+
const { getOpenCount, open, switchScrollingEffect } = this.props;
125124
const openCount = typeof getOpenCount === 'function' && getOpenCount()
126125
delete currentDrawer[this.drawerId];
127126
if (open) {
@@ -306,7 +305,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
306305
}
307306

308307
private addScrollingEffect = (right: number) => {
309-
const { placement, duration, ease, getOpenCount } = this.props;
308+
const { placement, duration, ease, getOpenCount, switchScrollingEffect } = this.props;
310309
const openCount = getOpenCount && getOpenCount();
311310
if (openCount === 1) {
312311
switchScrollingEffect();
@@ -337,7 +336,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
337336
}
338337

339338
private remScrollingEffect = (right: number) => {
340-
const { placement, duration, ease, getOpenCount } = this.props;
339+
const { placement, duration, ease, getOpenCount, switchScrollingEffect } = this.props;
341340
const openCount = getOpenCount && getOpenCount();
342341
if (!openCount) {
343342
switchScrollingEffect(true);
@@ -456,6 +455,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
456455
onHandleClick,
457456
keyboard,
458457
getOpenCount,
458+
switchScrollingEffect,
459459
...props
460460
} = this.props;
461461
// 首次渲染都将是关闭状态。

src/IDrawerPropTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ export interface IDrawerProps extends IProps {
4444
export interface IDrawerChildProps extends IProps {
4545
getContainer?: () => HTMLElement;
4646
getOpenCount?: () => number;
47+
switchScrollingEffect?: (close?: boolean) => void;
4748
}

0 commit comments

Comments
 (0)