@@ -21,6 +21,8 @@ import {
2121 ViewEncapsulation
2222} from '@angular/core' ;
2323import { takeUntilDestroyed , toSignal } from '@angular/core/rxjs-interop' ;
24+ import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
25+ import { of } from 'rxjs' ;
2426import { filter , map , switchMap , take , tap } from 'rxjs/operators' ;
2527
2628import { NzIconModule } from 'ng-zorro-antd/icon' ;
@@ -70,6 +72,7 @@ import { NzSegmentedService } from './segmented.service';
7072 encapsulation : ViewEncapsulation . None
7173} )
7274export class NzSegmentedItemComponent implements OnInit {
75+ private readonly animationType = inject ( ANIMATION_MODULE_TYPE , { optional : true } ) ;
7376 private readonly service = inject ( NzSegmentedService ) ;
7477 private readonly elementRef = inject ( ElementRef ) ;
7578 private readonly destroyRef = inject ( DestroyRef ) ;
@@ -98,13 +101,16 @@ export class NzSegmentedItemComponent implements OnInit {
98101 this . service . activated$ . next ( this . elementRef . nativeElement ) ;
99102 }
100103 } ) ,
101- switchMap ( value =>
102- this . service . animationDone$ . pipe (
104+ switchMap ( value => {
105+ if ( this . animationType === 'NoopAnimations' ) {
106+ return of ( value ) ;
107+ }
108+ return this . service . animationDone$ . pipe (
103109 filter ( event => event . toState === 'to' || event . toState === 'toVertical' ) ,
104110 take ( 1 ) ,
105111 map ( ( ) => value )
106- )
107- ) ,
112+ ) ;
113+ } ) ,
108114 filter ( value => value === this . nzValue ( ) ) ,
109115 takeUntilDestroyed ( this . destroyRef )
110116 )
0 commit comments