Skip to content

Commit 2b3f61f

Browse files
committed
chore: Use rc-motion instead of rc-animate
1 parent 3793138 commit 2b3f61f

File tree

5 files changed

+15
-61
lines changed

5 files changed

+15
-61
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"classnames": "^2.2.6",
6060
"raf": "^3.4.1",
6161
"rc-align": "^4.0.0",
62-
"rc-animate": "^3.0.0",
62+
"rc-motion": "^1.0.0",
6363
"rc-util": "^5.0.1"
6464
}
6565
}

src/Popup.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ import raf from 'raf';
44
import Align from 'rc-align';
55
import { composeRef } from 'rc-util/lib/ref';
66
import classNames from 'classnames';
7-
import RawCSSMotion from 'rc-animate/lib/CSSMotion';
7+
import CSSMotion, { CSSMotionProps } from 'rc-motion';
88
import PopupInner from './PopupInner';
99
import {
1010
StretchType,
1111
AlignType,
1212
TransitionNameType,
1313
AnimationType,
1414
Point,
15-
CSSMotionClass,
16-
MotionType,
1715
} from './interface';
1816
import { getMotion } from './utils/legacyUtil';
1917

@@ -38,8 +36,6 @@ type PopupStatus =
3836
| 'AfterMotion'
3937
| 'stable';
4038

41-
const CSSMotion = RawCSSMotion as CSSMotionClass;
42-
4339
interface PopupProps {
4440
visible?: boolean;
4541
style?: React.CSSProperties;
@@ -61,8 +57,8 @@ interface PopupProps {
6157
mask?: boolean;
6258

6359
// Motion
64-
motion: MotionType;
65-
maskMotion: MotionType;
60+
motion: CSSMotionProps;
61+
maskMotion: CSSMotionProps;
6662

6763
// Legacy
6864
animation: AnimationType;
@@ -87,7 +83,7 @@ interface AlignRefType {
8783
forceAlign: () => void;
8884
}
8985

90-
function supportMotion(motion: MotionType) {
86+
function supportMotion(motion: CSSMotionProps) {
9187
return motion && motion.motionName;
9288
}
9389

@@ -409,7 +405,7 @@ class Popup extends Component<PopupProps, PopupState> {
409405
return null;
410406
}
411407

412-
let motion: MotionType = {};
408+
let motion: CSSMotionProps = {};
413409

414410
if (maskMotion && maskMotion.motionName) {
415411
motion = {

src/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom';
33
import contains from 'rc-util/lib/Dom/contains';
44
import findDOMNode from 'rc-util/lib/Dom/findDOMNode';
55
import { composeRef, supportRef } from 'rc-util/lib/ref';
6+
import { CSSMotionProps } from 'rc-motion';
67
import addEventListener from 'rc-util/lib/Dom/addEventListener';
78
import Portal from 'rc-util/lib/Portal';
89
import classNames from 'classnames';
@@ -21,7 +22,6 @@ import {
2122
AnimationType,
2223
Point,
2324
CommonEventHandler,
24-
MotionType,
2525
} from './interface';
2626

2727
function noop() {}
@@ -80,10 +80,10 @@ export interface TriggerProps {
8080
stretch?: string;
8181
alignPoint?: boolean; // Maybe we can support user pass position in the future
8282

83-
/** Set popup motion. You can ref `rc-animate` for more info. */
84-
popupMotion?: MotionType;
85-
/** Set mask motion. You can ref `rc-animate` for more info. */
86-
maskMotion?: MotionType;
83+
/** Set popup motion. You can ref `rc-motion` for more info. */
84+
popupMotion?: CSSMotionProps;
85+
/** Set mask motion. You can ref `rc-motion` for more info. */
86+
maskMotion?: CSSMotionProps;
8787

8888
/** @deprecated Please us `popupMotion` instead. */
8989
popupTransitionName?: TransitionNameType;

src/interface.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -61,46 +61,3 @@ export interface Point {
6161
export interface CommonEventHandler {
6262
remove: () => void;
6363
}
64-
65-
// =================================== Motion ===================================
66-
type MotionStatus = 'none' | 'appear' | 'enter' | 'leave';
67-
68-
type MotionActiveStatus = 'appear-active' | 'enter-active' | 'leave-active';
69-
70-
type MotionNameObject = {
71-
[key in MotionStatus | MotionActiveStatus]?: string;
72-
};
73-
74-
type MotionEventHandler = (
75-
element: HTMLElement,
76-
event: React.TransitionEvent<HTMLElement> | React.AnimationEvent<HTMLElement> | undefined,
77-
) => React.CSSProperties | false | null | undefined | void;
78-
79-
export interface MotionType {
80-
motionName?: string | MotionNameObject;
81-
motionAppear?: boolean;
82-
motionEnter?: boolean;
83-
motionLeave?: boolean;
84-
motionLeaveImmediately?: boolean; // Trigger leave motion immediately
85-
removeOnLeave?: boolean;
86-
leavedClassName?: string;
87-
onAppearStart?: MotionEventHandler;
88-
onAppearActive?: MotionEventHandler;
89-
onAppearEnd?: MotionEventHandler;
90-
onEnterStart?: MotionEventHandler;
91-
onEnterActive?: MotionEventHandler;
92-
onEnterEnd?: MotionEventHandler;
93-
onLeaveStart?: MotionEventHandler;
94-
onLeaveActive?: MotionEventHandler;
95-
onLeaveEnd?: MotionEventHandler;
96-
}
97-
98-
export interface MotionProps extends MotionType {
99-
visible?: boolean;
100-
children: (
101-
props: { className: string; style: React.CSSProperties },
102-
ref: React.Ref<any>,
103-
) => React.ReactElement;
104-
}
105-
106-
export type CSSMotionClass = React.ComponentClass<MotionProps>;

src/utils/legacyUtil.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { MotionType, AnimationType, TransitionNameType } from '../interface';
1+
import { CSSMotionProps } from 'rc-motion';
2+
import { AnimationType, TransitionNameType } from '../interface';
23

34
interface GetMotionProps {
4-
motion: MotionType;
5+
motion: CSSMotionProps;
56
animation: AnimationType;
67
transitionName: TransitionNameType;
78
prefixCls: string;
@@ -12,7 +13,7 @@ export function getMotion({
1213
motion,
1314
animation,
1415
transitionName,
15-
}: GetMotionProps): MotionType {
16+
}: GetMotionProps): CSSMotionProps {
1617
if (motion) {
1718
return motion;
1819
}

0 commit comments

Comments
 (0)