當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript flex-layout.ObservableMedia類代碼示例

本文整理匯總了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;未經允許,請勿轉載。