@angular/flex-layout#MediaChange TypeScript Examples
The following examples show how to use
@angular/flex-layout#MediaChange.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: media-query.service.ts From nghacks with MIT License | 6 votes |
private _init(): void {
this._mediaObserver.asObservable()
.pipe(
debounceTime(500),
distinctUntilChanged()
)
.subscribe((change: MediaChange[]) => {
if (this.activeMediaQuery !== change[0].mqAlias) {
this.activeMediaQuery = change[0].mqAlias as any;
this.onMediaChange.next(change[0].mqAlias as any);
}
});
}
Example #2
Source File: matx-side-nav-toggle.directive.ts From matx-angular with MIT License | 6 votes |
initSideNav() {
this.isMobile = this.mediaObserver.isActive('xs') || this.mediaObserver.isActive('sm');
// console.log(this.isMobile)
this.updateSidenav();
this.screenSizeWatcher = this.mediaObserver.media$.subscribe((change: MediaChange) => {
this.isMobile = (change.mqAlias == 'xs') || (change.mqAlias == 'sm');
this.updateSidenav();
});
}
Example #3
Source File: match-media.service.ts From matx-angular with MIT License | 6 votes |
private init(): void
{
this.mediaObserver.media$
.subscribe((change: MediaChange) => {
if ( this.activeMediaQuery !== change.mqAlias )
{
this.activeMediaQuery = change.mqAlias;
this.onMediaChange.next(change.mqAlias);
}
});
}
Example #4
Source File: network.component.ts From blockcore-hub with MIT License | 5 votes |
ngAfterContentInit() {
// There is a bug with this, does not always trigger when navigating back and forth, and resizing.
// This means the number of grids sometimes defaults to 4, even though the screen is small.
this.mediaObservable = this.mediaObserver.media$.subscribe((change: MediaChange) => {
this.columns = this.gridByBreakpoint[change.mqAlias];
});
}
Example #5
Source File: features.component.ts From careydevelopmentcrm with MIT License | 5 votes |
private handleMediaChange(mediaChange: MediaChange) {
if (this.media.isActive('lt-md')) {
this.opened = false;
} else {
this.opened = true;
}
}
Example #6
Source File: features.component.ts From careydevelopmentcrm with MIT License | 5 votes |
constructor(private media: MediaObserver) {
this.mediaWatcher = this.media.media$.subscribe((mediaChange: MediaChange) => {
this.handleMediaChange(mediaChange);
})
}
Example #7
Source File: network.component.ts From EXOS-Core with MIT License | 5 votes |
ngAfterContentInit() {
// There is a bug with this, does not always trigger when navigating back and forth, and resizing.
// This means the number of grids sometimes defaults to 4, even though the screen is small.
this.mediaObservable = this.mediaObserver.media$.subscribe((change: MediaChange) => {
this.columns = this.gridByBreakpoint[change.mqAlias];
});
}
Example #8
Source File: app-breakpoint.service.ts From youpez-admin with MIT License | 5 votes |
init() {
this.activeMediaQueryWatcher = this.media.media$.subscribe((change: MediaChange) => {
this.activatedMqAlias = change.mqAlias
this.activeMediaQuery = change.mediaQuery
this.checkMediaQuery()
this.onResize()
})
}