Skip to content

Commit

Permalink
chore: Use rc-motion instead of rc-animate
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Aug 5, 2020
1 parent 1cac01e commit d45c4d4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -163,7 +163,7 @@ ReactDOM.render(
<td>openAnimation</td>
<td>{enter:function,leave:function}|String</td>
<th></th>
<td>animate when sub menu open or close. see rc-animate for object type.</td>
<td>animate when sub menu open or close. see rc-motion for object type.</td>
</tr>
<tr>
<td>openTransition</td>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -45,8 +45,8 @@
"classnames": "2.x",
"mini-store": "^3.0.1",
"omit.js": "^2.0.0",
"rc-animate": "^3.1.0",
"rc-trigger": "^4.2.0",
"rc-motion": "^1.0.1",
"rc-trigger": "^4.4.0",
"rc-util": "^5.0.1",
"resize-observer-polyfill": "^1.5.0",
"shallowequal": "^1.1.0"
Expand Down
6 changes: 3 additions & 3 deletions src/Menu.tsx
@@ -1,6 +1,7 @@
import * as React from 'react';
import { Provider, create } from 'mini-store';
import omit from 'omit.js';
import { CSSMotionProps } from 'rc-motion';
import SubPopupMenu, { getActiveKey } from './SubPopupMenu';
import { noop } from './util';
import {
Expand All @@ -15,7 +16,6 @@ import {
BuiltinPlacements,
TriggerSubMenuAction,
MenuClickEventHandler,
MotionType,
} from './interface';
import { getMotion } from './utils/legacyUtil';

Expand Down Expand Up @@ -47,10 +47,10 @@ export interface MenuProps
expandIcon?: RenderIconType;
overflowedIndicator?: React.ReactNode;
/** Menu motion define */
motion?: MotionType;
motion?: CSSMotionProps;

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

/** @deprecated Please use `motion` instead */
openTransitionName?: string;
Expand Down
7 changes: 3 additions & 4 deletions src/SubMenu.tsx
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';
import Trigger from 'rc-trigger';
import KeyCode from 'rc-util/lib/KeyCode';
import CSSMotion from 'rc-animate/lib/CSSMotion';
import CSSMotion, { CSSMotionProps } from 'rc-motion';
import classNames from 'classnames';
import { connect } from 'mini-store';
import SubPopupMenu, { SubPopupMenuProps } from './SubPopupMenu';
Expand All @@ -27,7 +27,6 @@ import {
BuiltinPlacements,
TriggerSubMenuAction,
HoverEventHandler,
MotionType,
} from './interface';
import { MenuItem } from './MenuItem';

Expand Down Expand Up @@ -100,7 +99,7 @@ export interface SubMenuProps {
className?: string;
popupClassName?: string;

motion?: MotionType;
motion?: CSSMotionProps;
direction?: 'ltr' | 'rtl';
}

Expand Down Expand Up @@ -431,7 +430,7 @@ export class SubMenu extends React.Component<SubMenuProps> {
// don't show transition on first rendering (no animation for opened menu)
// show appear transition if it's not visible (not sure why)
// show appear transition if it's not inline mode
const mergedMotion: MotionType = {
const mergedMotion: CSSMotionProps = {
...motion,
leavedClassName: `${rootPrefixCls}-hidden`,
removeOnLeave: false,
Expand Down
4 changes: 2 additions & 2 deletions src/SubPopupMenu.tsx
@@ -1,5 +1,6 @@
import * as React from 'react';
import { connect } from 'mini-store';
import { CSSMotionProps } from 'rc-motion';
import KeyCode from 'rc-util/lib/KeyCode';
import createChainedFunction from 'rc-util/lib/createChainedFunction';
import shallowEqual from 'shallowequal';
Expand All @@ -25,7 +26,6 @@ import {
MenuClickEventHandler,
MenuInfo,
TriggerSubMenuAction,
MotionType,
} from './interface';
import { MenuItem, MenuItemProps } from './MenuItem';
import { MenuItemGroupProps } from './MenuItemGroup';
Expand Down Expand Up @@ -151,7 +151,7 @@ export interface SubPopupMenuProps {
// [Legacy]
// openTransitionName?: string;
// openAnimation?: OpenAnimation;
motion?: MotionType;
motion?: CSSMotionProps;

direction?: 'ltr' | 'rtl';
}
Expand Down
5 changes: 0 additions & 5 deletions src/interface.ts
@@ -1,5 +1,3 @@
import { TransitionNameType, MotionType } from 'rc-trigger/lib/interface';

export type RenderIconType =
| React.ReactNode
| ((props: any) => React.ReactNode);
Expand Down Expand Up @@ -60,6 +58,3 @@ export type LegacyFunctionRef = (node: React.ReactInstance) => void;
export type BuiltinPlacements = Record<string, any>;

export type TriggerSubMenuAction = 'click' | 'hover';

// =================================== Motion ===================================
export { TransitionNameType, MotionType };
16 changes: 6 additions & 10 deletions src/utils/legacyUtil.ts
@@ -1,16 +1,12 @@
import warning from 'rc-util/lib/warning';
import {
MotionType,
TransitionNameType,
OpenAnimation,
MenuMode,
} from '../interface';
import { CSSMotionProps } from 'rc-motion';
import { OpenAnimation, MenuMode } from '../interface';

interface GetMotionProps {
motion?: MotionType;
defaultMotions?: Partial<{ [key in MenuMode | 'other']: MotionType }>;
motion?: CSSMotionProps;
defaultMotions?: Partial<{ [key in MenuMode | 'other']: CSSMotionProps }>;
openAnimation?: OpenAnimation;
openTransitionName?: TransitionNameType;
openTransitionName?: string;
prefixCls?: string;
}

Expand All @@ -28,7 +24,7 @@ export function getMotion(
}: GetMotionProps,
{ switchingModeFromInline }: GetMotionState,
menuMode: MenuMode,
): MotionType {
): CSSMotionProps {
if (motion) {
return motion;
}
Expand Down

1 comment on commit d45c4d4

@afc163
Copy link
Member

@afc163 afc163 commented on d45c4d4 Aug 5, 2020

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.