@@ -42,19 +42,13 @@ import { ToastrService } from './toastr.service';
42
42
state ( 'inactive' , style ( { opacity : 0 } ) ) ,
43
43
state ( 'active' , style ( { opacity : 1 } ) ) ,
44
44
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 }}' ) ) ,
53
47
] ) ,
54
48
] ,
55
49
preserveWhitespaces : false ,
56
50
standalone : true ,
57
- imports : [ NgIf ] ,
51
+ imports : [ NgIf ] ,
58
52
} )
59
53
export class Toast < ConfigPayload = any > implements OnDestroy {
60
54
message ?: string | null ;
@@ -67,13 +61,9 @@ export class Toast<ConfigPayload = any> implements OnDestroy {
67
61
/** a combination of toast type and options.toastClass */
68
62
@HostBinding ( 'class' ) toastClasses = '' ;
69
63
/** 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 } ;
77
67
} ;
78
68
79
69
/** hides component when waiting to be displayed */
@@ -97,15 +87,13 @@ export class Toast<ConfigPayload = any> implements OnDestroy {
97
87
constructor (
98
88
protected toastrService : ToastrService ,
99
89
public toastPackage : ToastPackage ,
100
- protected ngZone ?: NgZone
90
+ protected ngZone ?: NgZone ,
101
91
) {
102
92
this . message = toastPackage . message ;
103
93
this . title = toastPackage . title ;
104
94
this . options = toastPackage . config ;
105
95
this . originalTimeout = toastPackage . config . timeOut ;
106
- this . toastClasses = `${ toastPackage . toastType } ${
107
- toastPackage . config . toastClass
108
- } `;
96
+ this . toastClasses = `${ toastPackage . toastType } ${ toastPackage . config . toastClass } ` ;
109
97
this . sub = toastPackage . toastRef . afterActivate ( ) . subscribe ( ( ) => {
110
98
this . activateToast ( ) ;
111
99
} ) ;
@@ -118,6 +106,13 @@ export class Toast<ConfigPayload = any> implements OnDestroy {
118
106
this . sub3 = toastPackage . toastRef . countDuplicate ( ) . subscribe ( count => {
119
107
this . duplicatesCount = count ;
120
108
} ) ;
109
+ this . state = {
110
+ value : 'inactive' ,
111
+ params : {
112
+ easeTime : this . toastPackage . config . easeTime ,
113
+ easing : 'ease-in' ,
114
+ } ,
115
+ } ;
121
116
}
122
117
ngOnDestroy ( ) {
123
118
this . sub . unsubscribe ( ) ;
@@ -132,7 +127,10 @@ export class Toast<ConfigPayload = any> implements OnDestroy {
132
127
*/
133
128
activateToast ( ) {
134
129
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
+ ) {
136
134
this . outsideTimeout ( ( ) => this . remove ( ) , this . options . timeOut ) ;
137
135
this . hideTime = new Date ( ) . getTime ( ) + this . options . timeOut ;
138
136
if ( this . options . progressBar ) {
0 commit comments