本文整理汇总了TypeScript中@angular/flex-layout.ObservableMedia类的典型用法代码示例。如果您正苦于以下问题:TypeScript ObservableMedia类的具体用法?TypeScript ObservableMedia怎么用?TypeScript ObservableMedia使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObservableMedia类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: constructor
public constructor(
private readonly observableMedia: ObservableMedia,
) {
this.breakpoint = this.observableMedia.asObservable()
.startWith(null)
.combineLatest(
Observable.fromEvent(window, 'resize')
.debounceTime(100)
.startWith(null),
)
.map(([d, e]) => {
let mqAlias = d && d.mqAlias || null;
if (mqAlias == null) {
// Unknown/first-pass case, need to guess. Breakpoints based upon:
// https://github.com/angular/flex-layout/wiki/Responsive-API
mqAlias = 'xl';
if (window.innerWidth <= 600) {
mqAlias = 'xs';
} else if (window.innerWidth <= 960) {
mqAlias = 'sm';
} else if (window.innerWidth <= 1280) {
mqAlias = 'md';
} else if (window.innerWidth <= 1440) {
mqAlias = 'lg';
}
}
switch (mqAlias) {
default:
case 'xs':
return Breakpoint.XS;
case 'sm':
return Breakpoint.SM;
case 'md':
return Breakpoint.MD;
case 'lg':
return Breakpoint.LG;
case 'xl':
return Breakpoint.XL;
}
})
.publishReplay(1)
.refCount();
}
开发者ID:alantreadway,项目名称:miner-stats-ui,代码行数:45,代码来源:media-query.service.ts
示例2: ngOnInit
public ngOnInit() {
this.enableSideNav$ = this.media.asObservable()
.map(() =>
this.media.isActive('xs') || this.media.isActive('sm')
)
.startWith(this.media.isActive('xs') || this.media.isActive('sm'));
}
开发者ID:patrickhousley,项目名称:xyzzy-mean,代码行数:7,代码来源:app.component.ts
示例3: ngOnInit
ngOnInit() {
// auto adjust side nav only if not embed
this.isNarrowView = /*this.headerEnabled &&*/ (this.media.isActive('xs') || this.media.isActive('sm'));
this.media.subscribe((change: MediaChange) => {
this.isNarrowView = /*this.headerEnabled &&*/ (change.mqAlias === 'xs' || change.mqAlias === 'sm');
});
}
开发者ID:dasahcc,项目名称:helix,代码行数:7,代码来源:cluster.component.ts
示例4: ngOnInit
// -----------------------------------------------------------------------------------------------------
// @ Lifecycle hooks
// -----------------------------------------------------------------------------------------------------
/**
* On init
*/
ngOnInit(): void
{
// Register the sidenav to the service
this._fuseMatSidenavHelperService.setSidenav(this.fuseMatSidenavHelper, this._matSidenav);
if ( this._observableMedia.isActive(this.matIsLockedOpen) )
{
this.isLockedOpen = true;
this._matSidenav.mode = 'side';
this._matSidenav.toggle(true);
}
else
{
this.isLockedOpen = false;
this._matSidenav.mode = 'over';
this._matSidenav.toggle(false);
}
this._fuseMatchMediaService.onMediaChange
.pipe(takeUntil(this._unsubscribeAll))
.subscribe(() => {
if ( this._observableMedia.isActive(this.matIsLockedOpen) )
{
this.isLockedOpen = true;
this._matSidenav.mode = 'side';
this._matSidenav.toggle(true);
}
else
{
this.isLockedOpen = false;
this._matSidenav.mode = 'over';
this._matSidenav.toggle(false);
}
});
}
开发者ID:,项目名称:,代码行数:42,代码来源:
示例5: ngOnInit
ngOnInit() {
// Automatically close side menu on screens > sm breakpoint
this.media
.asObservable()
.pipe(filter((change: MediaChange) => change.mqAlias !== 'xs' && change.mqAlias !== 'sm'))
.subscribe(() => this.sidenav.close());
}
开发者ID:softsky,项目名称:softsky.github.io,代码行数:7,代码来源:shell.component.ts
示例6:
.subscribe(() => {
if ( this._observableMedia.isActive(this.matIsLockedOpen) )
{
this.isLockedOpen = true;
this._matSidenav.mode = 'side';
this._matSidenav.toggle(true);
}
else
{
this.isLockedOpen = false;
this._matSidenav.mode = 'over';
this._matSidenav.toggle(false);
}
});
开发者ID:,项目名称:,代码行数:14,代码来源:
示例7: ngOnInit
ngOnInit() {
const grid = new Map([
['xs', 1],
['sm', 2],
['md', 2],
['lg', 3],
['xl', 3]
]);
let start: number;
grid.forEach((cols, mqAlias) => {
if (this.observableMedia.isActive(mqAlias)) {
start = cols;
}
});
this.cols = this.observableMedia.asObservable()
.pipe(
map(change => grid.get(change.mqAlias)),
startWith(start)
);
}
开发者ID:offscale,项目名称:www,代码行数:20,代码来源:infographic.component.ts
示例8:
.map(() =>
this.media.isActive('xs') || this.media.isActive('sm')
开发者ID:patrickhousley,项目名称:xyzzy-mean,代码行数:2,代码来源:app.component.ts
示例9:
grid.forEach((cols, mqAlias) => {
if (this.observableMedia.isActive(mqAlias)) {
start = cols;
}
});
开发者ID:offscale,项目名称:www,代码行数:5,代码来源:infographic.component.ts
注:本文中的@angular/flex-layout.ObservableMedia类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论