@@ -32,13 +32,13 @@ let NEXT_ID = 0;
3232 * ```
3333 */
3434@Component ( {
35- animations : [
35+ animations : [
3636 trigger ( 'animate' , [
37- state ( 'show ' , style ( {
37+ state ( 'visible ' , style ( {
3838 opacity : 1
3939 } ) ) ,
40- transition ( '* => show ' , animate ( '.20s ease' ) ) ,
41- transition ( 'show => * ' , animate ( '.40s ease-out' ) )
40+ transition ( 'invisible => visible ' , animate ( '.20s ease' ) ) ,
41+ transition ( 'visible => invisible ' , animate ( '.40s ease-out' ) )
4242 ] )
4343 ] ,
4444 selector : 'igx-toast' ,
@@ -50,19 +50,9 @@ let NEXT_ID = 0;
5050 ` ]
5151} )
5252export class IgxToastComponent implements IToggleView , OnInit , OnDestroy {
53+ @HostBinding ( '@animate' )
54+ private _animationState = 'invisible' ;
5355 private _isVisible = false ;
54- /**
55- * Returns a list of available CSS classes.
56- * ```typescript
57- * let toastClasses = this.toast.CSS_CLASSES;
58- * ```
59- * @memberof IgxToastComponent
60- */
61- public readonly CSS_CLASSES = {
62- IGX_TOAST_BOTTOM : 'igx-toast--bottom' ,
63- IGX_TOAST_MIDDLE : 'igx-toast--middle' ,
64- IGX_TOAST_TOP : 'igx-toast--top'
65- } ;
6656
6757 /**
6858 * Sets/gets the `id` of the toast.
@@ -121,6 +111,7 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
121111 */
122112 @Output ( )
123113 public onHidden = new EventEmitter < IgxToastComponent > ( ) ;
114+
124115 /**
125116 * Sets/gets the `role` attribute.
126117 * If not set, `role` will have value `"alert"`.
@@ -134,6 +125,7 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
134125 */
135126 @Input ( )
136127 public role = 'alert' ;
128+
137129 /**
138130 * Sets/gets whether the toast will be hidden after the `displayTime` is over.
139131 * Default value is `true`.
@@ -186,7 +178,6 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
186178 public set isVisible ( value ) {
187179 this . _isVisible = value ;
188180 this . isVisibleChange . emit ( this . _isVisible ) ;
189-
190181 }
191182
192183 /**
@@ -232,6 +223,7 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
232223 public get element ( ) {
233224 return this . elementRef . nativeElement ;
234225 }
226+
235227 /**
236228 * @hidden
237229 */
@@ -253,6 +245,7 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
253245 clearInterval ( this . timeoutId ) ;
254246 this . onShowing . emit ( this ) ;
255247 this . isVisible = true ;
248+ this . _animationState = 'visible' ;
256249
257250 if ( this . autoHide ) {
258251 this . timeoutId = setTimeout ( ( ) => {
@@ -274,6 +267,7 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
274267 this . onHiding . emit ( this ) ;
275268 this . isVisible = false ;
276269 this . onHidden . emit ( this ) ;
270+ this . _animationState = 'invisible' ;
277271
278272 clearInterval ( this . timeoutId ) ;
279273 }
@@ -304,26 +298,22 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
304298 public toggle ( ) {
305299 this . isVisible ? this . close ( ) : this . open ( ) ;
306300 }
307- /**
308- * Sets/gets the class name of the toast based on the `position` value.
309- * ```typescript
310- * let className = this.toast.mapPositionToClassName();
311- * ```
312- * @memberof IgxToastComponent
313- */
314- public mapPositionToClassName ( ) : any {
315- if ( this . position === IgxToastPosition . Top ) {
316- return this . CSS_CLASSES . IGX_TOAST_TOP ;
317- }
318301
319- if ( this . position === IgxToastPosition . Middle ) {
320- return this . CSS_CLASSES . IGX_TOAST_MIDDLE ;
321- }
302+ @HostBinding ( 'class.igx-toast--top' )
303+ public get cssClassTop ( ) : boolean {
304+ return this . position === IgxToastPosition . Top ;
305+ }
322306
323- if ( this . position === IgxToastPosition . Bottom ) {
324- return this . CSS_CLASSES . IGX_TOAST_BOTTOM ;
325- }
307+ @HostBinding ( 'class.igx-toast--middle' )
308+ public get cssClassMiddle ( ) : boolean {
309+ return this . position === IgxToastPosition . Middle ;
310+ }
311+
312+ @HostBinding ( 'class.igx-toast--bottom' )
313+ public get cssClassBottom ( ) : boolean {
314+ return this . position === IgxToastPosition . Bottom ;
326315 }
316+
327317 /**
328318 * @hidden
329319 */
@@ -332,6 +322,7 @@ export class IgxToastComponent implements IToggleView, OnInit, OnDestroy {
332322 this . navService . add ( this . id , this ) ;
333323 }
334324 }
325+
335326 /**
336327 * @hidden
337328 */
0 commit comments