import { AfterContentInit , Directive , ElementRef , Input , NgZone } from '@angular/core' ; import Scrollbar from 'smooth-scrollbar' ; import { ScrollbarOptions } from 'smooth-scrollbar/interfaces' ; import { scrollbarOptions } from './scrollbar-options' ; @ Directive ( { selector : '[ngxScrollbar]' , } ) export class ScrollbarDirective implements AfterContentInit { @ Input ( ) options : Partial < ScrollbarOptions > ; scrollbarRef : Scrollbar ; constructor ( private element , private zone ) { } ngAfterContentInit ( ) { const options = Object . assign ( this . options , scrollbarOptions ) ; this . zone . runOutsideAngular ( ( ) => { this . scrollbarRef = Scrollbar . init ( this . element . nativeElement , options ) ; } ) ; } }