@@ -18,12 +18,13 @@ import { SidebarService } from '../sidebar.service';
18
18
import { SidebarComponent } from '../sidebar/sidebar.component' ;
19
19
import { Observable , Subscription } from 'rxjs' ;
20
20
import { filter } from 'rxjs/operators' ;
21
+ import { animate , AnimationEvent , state , style , transition , trigger } from '@angular/animations' ;
21
22
22
23
@Component ( {
23
24
selector : 'c-sidebar-nav' ,
24
25
templateUrl : './sidebar-nav.component.html' ,
25
26
styleUrls : [ './sidebar-nav.component.scss' ]
26
- } )
27
+ } )
27
28
export class SidebarNavComponent implements OnChanges {
28
29
@Input ( ) navItems ?: INavData [ ] = [ ] ;
29
30
@Input ( ) dropdownMode ?: 'closeInactive' | 'noAction' | 'openActive' = 'closeInactive' ;
@@ -63,7 +64,7 @@ export class SidebarNavComponent implements OnChanges {
63
64
public hideMobile ( ) : void {
64
65
// todo: proper scrollIntoView() after NavigationEnd
65
66
if ( this . sidebar && this . sidebar . sidebarState . mobile ) {
66
- this . sidebarService . toggle ( { toggle : 'visible' , sidebar : this . sidebar } ) ;
67
+ this . sidebarService . toggle ( { toggle : 'visible' , sidebar : this . sidebar } ) ;
67
68
}
68
69
}
69
70
}
@@ -72,7 +73,20 @@ export class SidebarNavComponent implements OnChanges {
72
73
selector : 'c-sidebar-nav-group' ,
73
74
templateUrl : './sidebar-nav-group.component.html' ,
74
75
styleUrls : [ './sidebar-nav-group.component.scss' ] ,
75
- providers : [ SidebarNavHelper ]
76
+ providers : [ SidebarNavHelper ] ,
77
+ animations : [
78
+ trigger ( 'openClose' , [
79
+ state ( 'open' , style ( {
80
+ height : '*'
81
+ } ) ) ,
82
+ state ( 'closed' , style ( {
83
+ height : '0px'
84
+ } ) ) ,
85
+ transition ( 'open <=> closed' , [
86
+ animate ( '.15s ease' )
87
+ ] )
88
+ ] )
89
+ ]
76
90
} )
77
91
export class SidebarNavGroupComponent implements OnInit , OnDestroy {
78
92
@Input ( ) item : any ;
@@ -85,7 +99,7 @@ export class SidebarNavGroupComponent implements OnInit, OnDestroy {
85
99
get hostClasses ( ) : any {
86
100
return {
87
101
'nav-group' : true ,
88
- show : this . open ,
102
+ show : this . open
89
103
} ;
90
104
}
91
105
@@ -96,8 +110,9 @@ export class SidebarNavGroupComponent implements OnInit, OnDestroy {
96
110
navSubscription : Subscription ;
97
111
98
112
// @ts -ignore
99
- private open : boolean ;
113
+ public open : boolean ;
100
114
public navItems : INavData [ ] = [ ] ;
115
+ public display : any = { display : 'block' } ;
101
116
102
117
constructor (
103
118
private router : Router ,
@@ -145,4 +160,18 @@ export class SidebarNavGroupComponent implements OnInit, OnDestroy {
145
160
ngOnDestroy ( ) : void {
146
161
this . navSubscription . unsubscribe ( ) ;
147
162
}
163
+
164
+ onAnimationStart ( $event : AnimationEvent ) {
165
+ setTimeout ( ( ) => {
166
+ this . display = { display : 'block' } ;
167
+ } ) ;
168
+ }
169
+
170
+ onAnimationDone ( $event : AnimationEvent ) {
171
+ if ( $event . toState === 'closed' ) {
172
+ setTimeout ( ( ) => {
173
+ this . display = null ;
174
+ } ) ;
175
+ }
176
+ }
148
177
}
0 commit comments