Skip to content

Commit d45c4d4

Browse files
committed
chore: Use rc-motion instead of rc-animate
1 parent 1cac01e commit d45c4d4

File tree

7 files changed

+17
-27
lines changed

7 files changed

+17
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ ReactDOM.render(
163163
<td>openAnimation</td>
164164
<td>{enter:function,leave:function}|String</td>
165165
<th></th>
166-
<td>animate when sub menu open or close. see rc-animate for object type.</td>
166+
<td>animate when sub menu open or close. see rc-motion for object type.</td>
167167
</tr>
168168
<tr>
169169
<td>openTransition</td>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
"classnames": "2.x",
4646
"mini-store": "^3.0.1",
4747
"omit.js": "^2.0.0",
48-
"rc-animate": "^3.1.0",
49-
"rc-trigger": "^4.2.0",
48+
"rc-motion": "^1.0.1",
49+
"rc-trigger": "^4.4.0",
5050
"rc-util": "^5.0.1",
5151
"resize-observer-polyfill": "^1.5.0",
5252
"shallowequal": "^1.1.0"

src/Menu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import { Provider, create } from 'mini-store';
33
import omit from 'omit.js';
4+
import { CSSMotionProps } from 'rc-motion';
45
import SubPopupMenu, { getActiveKey } from './SubPopupMenu';
56
import { noop } from './util';
67
import {
@@ -15,7 +16,6 @@ import {
1516
BuiltinPlacements,
1617
TriggerSubMenuAction,
1718
MenuClickEventHandler,
18-
MotionType,
1919
} from './interface';
2020
import { getMotion } from './utils/legacyUtil';
2121

@@ -47,10 +47,10 @@ export interface MenuProps
4747
expandIcon?: RenderIconType;
4848
overflowedIndicator?: React.ReactNode;
4949
/** Menu motion define */
50-
motion?: MotionType;
50+
motion?: CSSMotionProps;
5151

5252
/** Default menu motion of each mode */
53-
defaultMotions?: Partial<{ [key in MenuMode | 'other']: MotionType }>;
53+
defaultMotions?: Partial<{ [key in MenuMode | 'other']: CSSMotionProps }>;
5454

5555
/** @deprecated Please use `motion` instead */
5656
openTransitionName?: string;

src/SubMenu.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import * as ReactDOM from 'react-dom';
33
import Trigger from 'rc-trigger';
44
import KeyCode from 'rc-util/lib/KeyCode';
5-
import CSSMotion from 'rc-animate/lib/CSSMotion';
5+
import CSSMotion, { CSSMotionProps } from 'rc-motion';
66
import classNames from 'classnames';
77
import { connect } from 'mini-store';
88
import SubPopupMenu, { SubPopupMenuProps } from './SubPopupMenu';
@@ -27,7 +27,6 @@ import {
2727
BuiltinPlacements,
2828
TriggerSubMenuAction,
2929
HoverEventHandler,
30-
MotionType,
3130
} from './interface';
3231
import { MenuItem } from './MenuItem';
3332

@@ -100,7 +99,7 @@ export interface SubMenuProps {
10099
className?: string;
101100
popupClassName?: string;
102101

103-
motion?: MotionType;
102+
motion?: CSSMotionProps;
104103
direction?: 'ltr' | 'rtl';
105104
}
106105

@@ -431,7 +430,7 @@ export class SubMenu extends React.Component<SubMenuProps> {
431430
// don't show transition on first rendering (no animation for opened menu)
432431
// show appear transition if it's not visible (not sure why)
433432
// show appear transition if it's not inline mode
434-
const mergedMotion: MotionType = {
433+
const mergedMotion: CSSMotionProps = {
435434
...motion,
436435
leavedClassName: `${rootPrefixCls}-hidden`,
437436
removeOnLeave: false,

src/SubPopupMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import { connect } from 'mini-store';
3+
import { CSSMotionProps } from 'rc-motion';
34
import KeyCode from 'rc-util/lib/KeyCode';
45
import createChainedFunction from 'rc-util/lib/createChainedFunction';
56
import shallowEqual from 'shallowequal';
@@ -25,7 +26,6 @@ import {
2526
MenuClickEventHandler,
2627
MenuInfo,
2728
TriggerSubMenuAction,
28-
MotionType,
2929
} from './interface';
3030
import { MenuItem, MenuItemProps } from './MenuItem';
3131
import { MenuItemGroupProps } from './MenuItemGroup';
@@ -151,7 +151,7 @@ export interface SubPopupMenuProps {
151151
// [Legacy]
152152
// openTransitionName?: string;
153153
// openAnimation?: OpenAnimation;
154-
motion?: MotionType;
154+
motion?: CSSMotionProps;
155155

156156
direction?: 'ltr' | 'rtl';
157157
}

src/interface.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { TransitionNameType, MotionType } from 'rc-trigger/lib/interface';
2-
31
export type RenderIconType =
42
| React.ReactNode
53
| ((props: any) => React.ReactNode);
@@ -60,6 +58,3 @@ export type LegacyFunctionRef = (node: React.ReactInstance) => void;
6058
export type BuiltinPlacements = Record<string, any>;
6159

6260
export type TriggerSubMenuAction = 'click' | 'hover';
63-
64-
// =================================== Motion ===================================
65-
export { TransitionNameType, MotionType };

src/utils/legacyUtil.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import warning from 'rc-util/lib/warning';
2-
import {
3-
MotionType,
4-
TransitionNameType,
5-
OpenAnimation,
6-
MenuMode,
7-
} from '../interface';
2+
import { CSSMotionProps } from 'rc-motion';
3+
import { OpenAnimation, MenuMode } from '../interface';
84

95
interface GetMotionProps {
10-
motion?: MotionType;
11-
defaultMotions?: Partial<{ [key in MenuMode | 'other']: MotionType }>;
6+
motion?: CSSMotionProps;
7+
defaultMotions?: Partial<{ [key in MenuMode | 'other']: CSSMotionProps }>;
128
openAnimation?: OpenAnimation;
13-
openTransitionName?: TransitionNameType;
9+
openTransitionName?: string;
1410
prefixCls?: string;
1511
}
1612

@@ -28,7 +24,7 @@ export function getMotion(
2824
}: GetMotionProps,
2925
{ switchingModeFromInline }: GetMotionState,
3026
menuMode: MenuMode,
31-
): MotionType {
27+
): CSSMotionProps {
3228
if (motion) {
3329
return motion;
3430
}

0 commit comments

Comments
 (0)