@@ -29,9 +29,9 @@ import {
2929 host : { '[class]' : 'hostClasses()' , '[style]' : '{ display: "none" }' }
3030} )
3131export class CollapseDirective implements OnDestroy {
32+ readonly #animationBuilder = inject ( AnimationBuilder ) ;
3233 readonly #hostElement = inject ( ElementRef ) ;
3334 readonly #renderer = inject ( Renderer2 ) ;
34- readonly #animationBuilder = inject ( AnimationBuilder ) ;
3535 #player: AnimationPlayer | undefined = undefined ;
3636
3737 constructor ( ) {
@@ -158,7 +158,9 @@ export class CollapseDirective implements OnDestroy {
158158 this . #renderer. addClass ( host , 'collapsing' ) ;
159159 this . #renderer. removeClass ( host , 'show' ) ;
160160 this . #renderer. setStyle ( host , dimension , visible ? `${ ( host as any ) [ scrollSize ] } px` : '' ) ;
161- this . collapseChange ?. emit ( visible ? 'opening' : 'collapsing' ) ;
161+ if ( this . #player) {
162+ this . collapseChange ?. emit ( visible ? 'opening' : 'collapsing' ) ;
163+ }
162164 } ) ;
163165
164166 this . #player. onDone ( ( ) => {
@@ -170,9 +172,11 @@ export class CollapseDirective implements OnDestroy {
170172 } else {
171173 this . #renderer. removeClass ( host , 'show' ) ;
172174 }
173- this . collapseChange ?. emit ( visible ? 'open' : 'collapsed' ) ;
175+ if ( this . #player) {
176+ this . collapseChange ?. emit ( visible ? 'open' : 'collapsed' ) ;
177+ this . visibleChange ?. emit ( visible ) ;
178+ }
174179 this . destroyPlayer ( ) ;
175- this . visibleChange . emit ( visible ) ;
176180 } ) ;
177181
178182 this . #player?. play ( ) ;
0 commit comments