mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 04:25:08 +00:00
(MatchMediaService) Added a debounce so that the layout changes can work a lot more stable on media changes
This commit is contained in:
parent
08e2d5f331
commit
f7f3a60ff5
|
@ -1,6 +1,7 @@
|
||||||
import { MediaChange, ObservableMedia } from '@angular/flex-layout';
|
import { MediaChange, ObservableMedia } from '@angular/flex-layout';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -38,7 +39,11 @@ export class FuseMatchMediaService
|
||||||
*/
|
*/
|
||||||
private _init(): void
|
private _init(): void
|
||||||
{
|
{
|
||||||
this._observableMedia
|
this._observableMedia.asObservable()
|
||||||
|
.pipe(
|
||||||
|
debounceTime(500),
|
||||||
|
distinctUntilChanged()
|
||||||
|
)
|
||||||
.subscribe((change: MediaChange) => {
|
.subscribe((change: MediaChange) => {
|
||||||
if ( this.activeMediaQuery !== change.mqAlias )
|
if ( this.activeMediaQuery !== change.mqAlias )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user