@angular/cdk/layout#MediaMatcher TypeScript Examples
The following examples show how to use
@angular/cdk/layout#MediaMatcher.
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: side-bar.component.ts From Smersh with MIT License | 6 votes |
constructor(
changeDetectorRef: ChangeDetectorRef,
media: MediaMatcher,
private connection: ConnectionService,
public themeService: ThemeService,
public localeService: LocaleService,
private translate: TranslateService
) {
this.mobileQuery = media.matchMedia('(max-width: 600px)');
this._mobileQueryListener = () => changeDetectorRef.detectChanges();
this.mobileQuery.addListener(this._mobileQueryListener);
Object.entries({
Mission: MissionRouter.redirectToList(),
Vuln: VulnRouter.redirectToList(),
Host: HostRouter.redirectToList(),
User: UserRouter.redirectToList(),
Impact: ImpactRouter.redirectToList(),
Client: ClientRouter.redirectToList(),
})
.filter(([k]) => isGranted(`ROLE_${k.toUpperCase()}_GET_LIST`))
.map(([k, v]) => (this.fillerNav[`${k}s`] = v));
}
Example #2
Source File: full.component.ts From flingo with MIT License | 6 votes |
constructor(
public router: Router,
changeDetectorRef: ChangeDetectorRef,
media: MediaMatcher,
public menuItems: MenuItems,
private progress: ProgressService
) {
this.mobileQuery = media.matchMedia('(min-width: 920px)');
this._mobileQueryListener = () => changeDetectorRef.detectChanges();
// tslint:disable-next-line: deprecation
this.mobileQuery.addListener(this._mobileQueryListener);
this.isLoading$ = this.progress.progress$;
}
Example #3
Source File: viewport.service.ts From App with MIT License | 5 votes |
constructor(
@Inject(DOCUMENT) private document: Document,
private windowRef: WindowRef,
private ngZone: NgZone, media: MediaMatcher,
renderFactory2: RendererFactory2
) {
this.query.xs = media.matchMedia('(max-width: 576px)');
this.query.sm = media.matchMedia('(min-width: 576px)');
this.query.md = media.matchMedia('(min-width: 768px)');
this.query.lg = media.matchMedia('(min-width: 992px)');
this.query.xl = media.matchMedia('(min-width: 1200px)');
(() => {
let index = 0;
for (const size of this.BREAKPOINT_NAMES) {
++index;
this.queryIndex[index] = size;
}
})();
AppComponent.isBrowser.pipe(
filter(isBrowser => isBrowser === true),
tap(() => {
const win = this.windowRef.getNativeWindow();
if (!win) return;
win.onresize = (ev: UIEvent) => {
this.ngZone.run(() => {
this.height = document.body.offsetHeight;
this.width = document.body.offsetWidth;
this.appResize.emit('window');
this.checkBreakpoint();
});
};
})
).subscribe();
this.height = document.body.offsetHeight;
this.width = document.body.offsetWidth;
this.checkBreakpoint();
// Update mouse position
{
const renderer = renderFactory2.createRenderer(null, null);
renderer.listen('document', 'mousemove', (ev: MouseEvent) => {
this.mouseX = ev.x;
this.mouseY = ev.y;
});
}
}
Example #4
Source File: layout.component.ts From angular-material-admin with MIT License | 5 votes |
constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher) {
this.mobileQuery = media.matchMedia('(max-width: 1024px)');
this.mobileQueryListener = () => changeDetectorRef.detectChanges();
this.mobileQuery.addListener(this.mobileQueryListener);
this.isShowSidebar = !this.mobileQuery.matches;
}
Example #5
Source File: sidebar.component.ts From flingo with MIT License | 5 votes |
constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher, public menuItems: MenuItems) {
this.mobileQuery = media.matchMedia('(min-width: 768px)');
this._mobileQueryListener = () => changeDetectorRef.detectChanges();
// tslint:disable-next-line: deprecation
this.mobileQuery.addListener(this._mobileQueryListener);
}
Example #6
Source File: responsive-sidenav.component.ts From matx-angular with MIT License | 5 votes |
constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher) {
this.mobileQuery = media.matchMedia('(max-width: 600px)');
this._mobileQueryListener = () => changeDetectorRef.detectChanges();
this.mobileQuery.addListener(this._mobileQueryListener);
}