import { Directive , ElementRef , OnDestroy , OnInit , Renderer2 } from '@angular/core' ; import { Subject } from 'rxjs' ; import { takeUntil } from 'rxjs/operators' ; import { FuseMatchMediaService } from '@fuse/services/match-media.service' ; @ Directive ( { selector : '.inner-scroll' } ) export class FuseInnerScrollDirective implements OnInit , OnDestroy { private _parent : any ; private _grandParent : any ; private _unsubscribeAll : Subject < any > ; param { ElementRef } _elementRef param { FuseMatchMediaService } _fuseMediaMatchService param { Renderer2 } _renderer constructor ( private _elementRef , private _fuseMediaMatchService , private _renderer ) { this . _unsubscribeAll = new Subject ( ) ; } /**
     * On init
     */ ngOnInit ( ) { this . _parent = this . _renderer . parentNode ( this . _elementRef . nativeElement ) ; if ( ! this . _parent ) { return ; } this . _grandParent = this . _renderer . parentNode ( this . _parent ) ; this . _fuseMediaMatchService . onMediaChange . pipe ( takeUntil ( this . _unsubscribeAll ) ) . subscribe ( ( alias ) => { if ( alias === 'xs' ) { this . _removeClass ( ) ; } else { this . _addClass ( ) ; } } ) ; } /**
     * On destroy
     */ ngOnDestroy ( ) { if ( ! this . _parent ) { return ; } this . _removeClass ( ) ; this . _unsubscribeAll . next ( ) ; this . _unsubscribeAll . complete ( ) ; } private private _addClass ( ) { this . _renderer . addClass ( this . _grandParent , 'inner-scroll' ) ; } private private _removeClass ( ) { this . _renderer . removeClass ( this . _grandParent , 'inner-scroll' ) ; } }