Skip to content

Commit

Permalink
fix(submenu): fix submenu animation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yehuozhili committed Jun 3, 2020
1 parent 85a02f2 commit 96edbf7
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 5 deletions.
72 changes: 71 additions & 1 deletion src/components/Menu/_style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
top:calc(100% + #{$menu-item-padding-y});
white-space: nowrap;
left: 50%;
transform: translateX(-50%);
background: $white;
border: $menu-item-active-border-width solid transparent;
box-shadow: $submenu-box-shadow;
Expand Down Expand Up @@ -137,3 +136,74 @@
}
}
}



.menu-zoom-in-top-enter {
opacity: 0;
transform: scaleY(0) translateX(-50%) ;
top:calc(100% + #{$menu-item-padding-y});
}
.menu-zoom-in-top-enter-active {
opacity: 1;
transform: scaleY(1) translateX(-50%) ;
transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms, opacity 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms;
transform-origin: center top;
top:calc(100% + #{$menu-item-padding-y});
}

.menu-zoom-in-top-enter-done {
opacity: 1;
transform: scaleY(1) translateX(-50%) ;
transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms, opacity 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms;
transform-origin: center top;
top:calc(100% + #{$menu-item-padding-y});
}

.menu-zoom-in-top-exit {
opacity: 1;
transform: scaleY(1) translateX(-50%) ;
top:calc(100% + #{$menu-item-padding-y});
}
.menu-zoom-in-top-exit-active {
opacity: 0;
transform: scaleY(0) translateX(-50%) ;
transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms, opacity 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms;
transform-origin:center top;
top:calc(100% + #{$menu-item-padding-y});
}


.bigbear-submenu-children.menu-zoom-in-top-vertical-enter {
opacity: 0;
transform: scaleY(0) translateX(0) ;
top:calc(100% + #{$menu-item-padding-y});
}
.bigbear-submenu-children.menu-zoom-in-top-vertical-enter-active {
opacity: 1;
transform: scaleY(1) translateX(0) ;
transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms, opacity 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms;
transform-origin: center top;
top:calc(100% + #{$menu-item-padding-y});
}

.bigbear-submenu-children.menu-zoom-in-top-vertical-enter-done {
opacity: 1;
transform: scaleY(1) translateX(0) ;
transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms, opacity 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms;
transform-origin: center top;
top:calc(100% + #{$menu-item-padding-y});
}

.bigbear-submenu-children.menu-zoom-in-top-vertical-exit {
opacity: 1;
transform: scaleY(1) translateX(0) ;
top:calc(100% + #{$menu-item-padding-y});
}
.bigbear-submenu-children.menu-zoom-in-top-vertical-exit-active {
opacity: 0;
transform: scaleY(0) translateX(0) ;
transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms, opacity 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms;
transform-origin:center top;
top:calc(100% + #{$menu-item-padding-y});
}
8 changes: 4 additions & 4 deletions src/components/Menu/submenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface SubMenuProps{
style?:CSSProperties
}

const renderChildren = (children:React.ReactNode,menuopen:boolean,index:string|undefined) => {
const renderChildren = (children:React.ReactNode,menuopen:boolean,index:string|undefined,mode:"horizontal" | "vertical" | undefined) => {
const classes =classNames('bigbear-submenu-children',{
'bigbear-menuopen':menuopen
})
Expand All @@ -37,7 +37,7 @@ const renderChildren = (children:React.ReactNode,menuopen:boolean,index:string|u
<Transition
in={menuopen}
timeout={300}
animation='zoom-in-top'
classNames={mode==='horizontal'?'menu-zoom-in-top':'menu-zoom-in-top-vertical'}
>
<ul className={classes} >
{childrenComponent}
Expand Down Expand Up @@ -78,12 +78,12 @@ export const SubMenu:FC<SubMenuProps>=(props)=>{
}
},[isopen])
return (
<li key={index} className={classes} style={style} onClick={handleClick} {...hoverEvents}>
<li key={index} className={classes} style={style} onClick={handleClick} {...hoverEvents } >
<div onClick={()=>context.mode==='vertical'?setMenuopen(!menuopen):null} className='bigbear-submenu-title'>
{title?title:null}
<Icon icon="angle-down" className='bigbear-submenu-icon'></Icon>
</div>
{renderChildren(children,menuopen,index)}
{renderChildren(children,menuopen,index,context.mode)}
</li>
)
}
Expand Down

0 comments on commit 96edbf7

Please sign in to comment.