Skip to content

Commit

Permalink
Merge pull request #120 from react-component/refactor-switch-scrollin…
Browse files Browse the repository at this point in the history
…g-effect

refactor: use rc-util Portal switchScrollingEffect
  • Loading branch information
jljsj33 authored Dec 13, 2019
2 parents 9cbfeff + 31484de commit 16b9121
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"dependencies": {
"babel-runtime": "^6.26.0",
"classnames": "^2.2.6",
"rc-util": "^4.11.2",
"rc-util": "^4.16.1",
"react-lifecycles-compat": "^3.0.4"
}
}
8 changes: 4 additions & 4 deletions src/DrawerChild.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import classnames from 'classnames';
import getScrollBarSize from 'rc-util/lib/getScrollBarSize';
import KeyCode from 'rc-util/lib/KeyCode';
import switchScrollingEffect from 'rc-util/lib/switchScrollingEffect';
import * as React from 'react';
import { polyfill } from 'react-lifecycles-compat';

Expand Down Expand Up @@ -121,7 +120,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
}

public componentWillUnmount() {
const { getOpenCount, open } = this.props;
const { getOpenCount, open, switchScrollingEffect } = this.props;
const openCount = typeof getOpenCount === 'function' && getOpenCount()
delete currentDrawer[this.drawerId];
if (open) {
Expand Down Expand Up @@ -306,7 +305,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
}

private addScrollingEffect = (right: number) => {
const { placement, duration, ease, getOpenCount } = this.props;
const { placement, duration, ease, getOpenCount, switchScrollingEffect } = this.props;
const openCount = getOpenCount && getOpenCount();
if (openCount === 1) {
switchScrollingEffect();
Expand Down Expand Up @@ -337,7 +336,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
}

private remScrollingEffect = (right: number) => {
const { placement, duration, ease, getOpenCount } = this.props;
const { placement, duration, ease, getOpenCount, switchScrollingEffect } = this.props;
const openCount = getOpenCount && getOpenCount();
if (!openCount) {
switchScrollingEffect(true);
Expand Down Expand Up @@ -456,6 +455,7 @@ class DrawerChild extends React.Component<IDrawerChildProps, IState> {
onHandleClick,
keyboard,
getOpenCount,
switchScrollingEffect,
...props
} = this.props;
// 首次渲染都将是关闭状态。
Expand Down
1 change: 1 addition & 0 deletions src/IDrawerPropTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ export interface IDrawerProps extends IProps {
export interface IDrawerChildProps extends IProps {
getContainer?: () => HTMLElement;
getOpenCount?: () => number;
switchScrollingEffect?: (close?: boolean) => void;
}

1 comment on commit 16b9121

@vercel
Copy link

@vercel vercel bot commented on 16b9121 Dec 13, 2019

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.