@addapptables/perfect-scrollbar
Version:
Perfect scrollbar library for angular
106 lines (102 loc) • 3.05 kB
JavaScript
import { Directive, ElementRef, Input, HostListener, NgModule } from '@angular/core';
import PerfectScrollbar from 'perfect-scrollbar';
import { NavigationEnd, NavigationError, NavigationCancel, Router } from '@angular/router';
import { filter, delay } from 'rxjs/operators';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class PerfectScrollbarDirective {
/**
* @param {?} _elementRef
* @param {?} _router
*/
constructor(_elementRef, _router) {
this._elementRef = _elementRef;
this._router = _router;
this.allSub = new Array();
this.options = {};
}
/**
* @param {?} value
* @return {?}
*/
set perfectScrollOptions(value) {
this.options = value;
}
/**
* @return {?}
*/
onResize() {
this.ps && this.ps.update();
}
/**
* @return {?}
*/
ngAfterViewInit() {
this.initPerfectScroll();
/** @type {?} */
const navigationEnd$ = this._router.events
.pipe(filter((/**
* @param {?} event
* @return {?}
*/
(event) => event instanceof NavigationEnd || event instanceof NavigationError || event instanceof NavigationCancel)), delay(100))
.subscribe((/**
* @return {?}
*/
() => {
this.ps && this.ps.update();
}));
this.allSub.push(navigationEnd$);
}
/**
* @return {?}
*/
initPerfectScroll() {
this.ps = new PerfectScrollbar(this._elementRef.nativeElement, {});
}
/**
* @return {?}
*/
ngOnDestroy() {
this.ps && this.ps.destroy();
this.allSub.forEach((/**
* @param {?} x
* @return {?}
*/
x => x.unsubscribe()));
}
}
PerfectScrollbarDirective.decorators = [
{ type: Directive, args: [{
selector: '[addapptablesPerfectScrollbar]'
},] }
];
/** @nocollapse */
PerfectScrollbarDirective.ctorParameters = () => [
{ type: ElementRef },
{ type: Router }
];
PerfectScrollbarDirective.propDecorators = {
perfectScrollOptions: [{ type: Input }],
onResize: [{ type: HostListener, args: ['window:resize',] }]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class AddapptablePerfectScrollbarModule {
}
AddapptablePerfectScrollbarModule.decorators = [
{ type: NgModule, args: [{
declarations: [
PerfectScrollbarDirective
],
exports: [
PerfectScrollbarDirective
]
},] }
];
export { AddapptablePerfectScrollbarModule, PerfectScrollbarDirective };
//# sourceMappingURL=addapptables-perfect-scrollbar.js.map