Add animation for dropdown submenu, ref #797

This commit is contained in:
afc163 2015-12-31 17:55:45 +08:00
parent d79562075a
commit ba51e65c3d
3 changed files with 37 additions and 24 deletions

View File

@ -9,8 +9,12 @@ export default React.createClass({
}; };
}, },
render: function () { render: function () {
const { overlay, ...otherProps } = this.props;
const menu = React.cloneElement(overlay, {
openTransitionName: 'zoom-big',
});
return ( return (
<Dropdown {...this.props} /> <Dropdown {...otherProps} overlay={menu} />
); );
} }
}); });

View File

@ -40,35 +40,43 @@ const AntMenu = React.createClass({
this.props.onClose(e); this.props.onClose(e);
}, },
render() { render() {
let openAnimation = ''; let openAnimation = this.props.openAnimation || this.props.openTransitionName;
switch (this.props.mode) { if (!openAnimation) {
case 'horizontal': switch (this.props.mode) {
openAnimation = 'slide-up'; case 'horizontal':
break; openAnimation = 'slide-up';
case 'vertical': break;
openAnimation = 'zoom-big'; case 'vertical':
break; openAnimation = 'zoom-big';
case 'inline': break;
openAnimation = animation; case 'inline':
break; openAnimation = animation;
default: break;
default:
}
} }
// let props = {};
//
// 使
let props = {
openKeys: this.state.openKeys,
onClick: this.handleClick,
onOpen: this.handleOpenKeys,
onClose: this.handleCloseKeys,
};
const className = this.props.className + ' ' + this.props.prefixCls + '-' + this.props.theme; const className = this.props.className + ' ' + this.props.prefixCls + '-' + this.props.theme;
if (this.props.mode === 'inline') { if (this.props.mode === 'inline') {
return <Menu {...this.props} className={className} openAnimation={openAnimation} />; //
//
// 使
props = {
openKeys: this.state.openKeys,
onClick: this.handleClick,
onOpen: this.handleOpenKeys,
onClose: this.handleCloseKeys,
openAnimation,
className,
};
} else { } else {
return <Menu {...this.props} {...props} className={className} openTransitionName={openAnimation} />; props = {
openTransitionName: openAnimation,
className,
};
} }
return <Menu {...this.props} {...props} />;
} }
}); });

View File

@ -118,6 +118,7 @@
position: absolute; position: absolute;
min-width: 100%; min-width: 100%;
margin-left: 4px; margin-left: 4px;
transform-origin: 0 0;
} }
&-submenu:first-child &-submenu-title { &-submenu:first-child &-submenu-title {