Skip to content

Commit

Permalink
feat(module:menu): animate expand/collapse menu (#330)
Browse files Browse the repository at this point in the history
close #25
  • Loading branch information
maroon1 authored and vthinkxie committed Sep 30, 2017
1 parent ca42f00 commit 7edba94
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/menu/nz-submenu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ import { debounceTime } from 'rxjs/operator/debounceTime';
style({ opacity: '0' }),
animate(150, style({ opacity: 1 }))
])
]),
trigger('expandAnimation', [
transition('expand => void', [
style({ height: '*', overflow: 'hidden' }),
animate(150, style({ height: 0 }))
]),
transition('void => expand', [
style({ height: 0, overflow: 'hidden' }),
animate(150, style({ height: '*' }))
])
])
],
template : `
Expand All @@ -34,6 +44,7 @@ import { debounceTime } from 'rxjs/operator/debounceTime';
<ul
[class.ant-dropdown-menu]="isInDropDown"
[@fadeAnimation]
[@expandAnimation]="expandState"
[class.ant-menu]="!isInDropDown"
[class.ant-dropdown-menu-vertical]="isInDropDown"
[class.ant-menu-vertical]="(!isInDropDown)&&(nzMenuComponent.nzMode!=='inline')"
Expand Down Expand Up @@ -64,6 +75,13 @@ export class NzSubMenuComponent implements OnInit, OnDestroy, AfterViewInit {
return !!this.subMenus._results.find(e => e !== this && e.subItemSelected)
}

get expandState() {
if (this.nzOpen && this.nzMenuComponent.nzMode !== 'vertical') {
return 'expand';
}
return null;
}

clickSubMenuTitle() {
if ((this.nzMenuComponent.nzMode === 'inline') || (!this.isInDropDown)) {
this.nzOpen = !this.nzOpen;
Expand Down

0 comments on commit 7edba94

Please sign in to comment.