@@ -42,19 +42,13 @@ import { ToastrService } from './toastr.service';
4242 state ( 'inactive' , style ( { opacity : 0 } ) ) ,
4343 state ( 'active' , style ( { opacity : 1 } ) ) ,
4444 state ( 'removed' , style ( { opacity : 0 } ) ) ,
45- transition (
46- 'inactive => active' ,
47- animate ( '{{ easeTime }}ms {{ easing }}' ) ,
48- ) ,
49- transition (
50- 'active => removed' ,
51- animate ( '{{ easeTime }}ms {{ easing }}' ) ,
52- ) ,
45+ transition ( 'inactive => active' , animate ( '{{ easeTime }}ms {{ easing }}' ) ) ,
46+ transition ( 'active => removed' , animate ( '{{ easeTime }}ms {{ easing }}' ) ) ,
5347 ] ) ,
5448 ] ,
5549 preserveWhitespaces : false ,
5650 standalone : true ,
57- imports : [ NgIf ] ,
51+ imports : [ NgIf ] ,
5852} )
5953export class Toast < ConfigPayload = any > implements OnDestroy {
6054 message ?: string | null ;
@@ -67,13 +61,9 @@ export class Toast<ConfigPayload = any> implements OnDestroy {
6761 /** a combination of toast type and options.toastClass */
6862 @HostBinding ( 'class' ) toastClasses = '' ;
6963 /** controls animation */
70- @HostBinding ( '@flyInOut' )
71- state = {
72- value : 'inactive' ,
73- params : {
74- easeTime : this . toastPackage . config . easeTime ,
75- easing : 'ease-in'
76- }
64+ @HostBinding ( '@flyInOut' ) state ! : {
65+ value : 'inactive' | 'active' | 'removed' ;
66+ params : { easeTime : number | string ; easing : string } ;
7767 } ;
7868
7969 /** hides component when waiting to be displayed */
@@ -97,15 +87,13 @@ export class Toast<ConfigPayload = any> implements OnDestroy {
9787 constructor (
9888 protected toastrService : ToastrService ,
9989 public toastPackage : ToastPackage ,
100- protected ngZone ?: NgZone
90+ protected ngZone ?: NgZone ,
10191 ) {
10292 this . message = toastPackage . message ;
10393 this . title = toastPackage . title ;
10494 this . options = toastPackage . config ;
10595 this . originalTimeout = toastPackage . config . timeOut ;
106- this . toastClasses = `${ toastPackage . toastType } ${
107- toastPackage . config . toastClass
108- } `;
96+ this . toastClasses = `${ toastPackage . toastType } ${ toastPackage . config . toastClass } ` ;
10997 this . sub = toastPackage . toastRef . afterActivate ( ) . subscribe ( ( ) => {
11098 this . activateToast ( ) ;
11199 } ) ;
@@ -118,6 +106,13 @@ export class Toast<ConfigPayload = any> implements OnDestroy {
118106 this . sub3 = toastPackage . toastRef . countDuplicate ( ) . subscribe ( count => {
119107 this . duplicatesCount = count ;
120108 } ) ;
109+ this . state = {
110+ value : 'inactive' ,
111+ params : {
112+ easeTime : this . toastPackage . config . easeTime ,
113+ easing : 'ease-in' ,
114+ } ,
115+ } ;
121116 }
122117 ngOnDestroy ( ) {
123118 this . sub . unsubscribe ( ) ;
@@ -132,7 +127,10 @@ export class Toast<ConfigPayload = any> implements OnDestroy {
132127 */
133128 activateToast ( ) {
134129 this . state = { ...this . state , value : 'active' } ;
135- if ( ! ( this . options . disableTimeOut === true || this . options . disableTimeOut === 'timeOut' ) && this . options . timeOut ) {
130+ if (
131+ ! ( this . options . disableTimeOut === true || this . options . disableTimeOut === 'timeOut' ) &&
132+ this . options . timeOut
133+ ) {
136134 this . outsideTimeout ( ( ) => this . remove ( ) , this . options . timeOut ) ;
137135 this . hideTime = new Date ( ) . getTime ( ) + this . options . timeOut ;
138136 if ( this . options . progressBar ) {
0 commit comments