@@ -33,6 +33,7 @@ import {
33
33
PortalHostDirective ,
34
34
} from '@angular/cdk/portal' ;
35
35
import { first } from '@angular/cdk/rxjs' ;
36
+ import { BreakpointObserver , BreakpointState , Breakpoints } from '@angular/cdk/layout' ;
36
37
import { Observable } from 'rxjs/Observable' ;
37
38
import { Subject } from 'rxjs/Subject' ;
38
39
import { MatSnackBarConfig } from './snack-bar-config' ;
@@ -58,6 +59,7 @@ export const HIDE_ANIMATION = '195ms cubic-bezier(0.0,0.0,0.2,1)';
58
59
host : {
59
60
'role' : 'alert' ,
60
61
'class' : 'mat-snack-bar-container' ,
62
+ '[class.mobile]' : '_isHandset' ,
61
63
'[@state]' : '_animationState' ,
62
64
'(@state.done)' : 'onAnimationEnd($event)'
63
65
} ,
@@ -90,6 +92,9 @@ export class MatSnackBarContainer extends BasePortalHost implements OnDestroy {
90
92
/** Subject for notifying that the snack bar has finished entering the view. */
91
93
_onEnter : Subject < any > = new Subject ( ) ;
92
94
95
+ /** Whether the snackbar is currently displaying on a mobile screen.. */
96
+ _isHandset : boolean ;
97
+
93
98
/** The state of the snack bar animations. */
94
99
_animationState = 'void' ;
95
100
@@ -100,8 +105,12 @@ export class MatSnackBarContainer extends BasePortalHost implements OnDestroy {
100
105
private _ngZone : NgZone ,
101
106
private _renderer : Renderer2 ,
102
107
private _elementRef : ElementRef ,
103
- private _changeDetectorRef : ChangeDetectorRef ) {
108
+ private _changeDetectorRef : ChangeDetectorRef ,
109
+ breakpointObserver : BreakpointObserver ) {
104
110
super ( ) ;
111
+ // Listen for the screen matcheing the `Handset` breakpoint to adjust snackbar styling.
112
+ breakpointObserver . observe ( Breakpoints . Handset ) . subscribe (
113
+ breakpointState => this . _isHandset = breakpointState . matches ) ;
105
114
}
106
115
107
116
/** Attach a component portal as content to this snack bar container. */
0 commit comments