UNPKG

@addapptables/perfect-scrollbar

Version:
123 lines (119 loc) 3.91 kB
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 */ var PerfectScrollbarDirective = /** @class */ (function () { function PerfectScrollbarDirective(_elementRef, _router) { this._elementRef = _elementRef; this._router = _router; this.allSub = new Array(); this.options = {}; } Object.defineProperty(PerfectScrollbarDirective.prototype, "perfectScrollOptions", { set: /** * @param {?} value * @return {?} */ function (value) { this.options = value; }, enumerable: true, configurable: true }); /** * @return {?} */ PerfectScrollbarDirective.prototype.onResize = /** * @return {?} */ function () { this.ps && this.ps.update(); }; /** * @return {?} */ PerfectScrollbarDirective.prototype.ngAfterViewInit = /** * @return {?} */ function () { var _this = this; this.initPerfectScroll(); /** @type {?} */ var navigationEnd$ = this._router.events .pipe(filter((/** * @param {?} event * @return {?} */ function (event) { return event instanceof NavigationEnd || event instanceof NavigationError || event instanceof NavigationCancel; })), delay(100)) .subscribe((/** * @return {?} */ function () { _this.ps && _this.ps.update(); })); this.allSub.push(navigationEnd$); }; /** * @return {?} */ PerfectScrollbarDirective.prototype.initPerfectScroll = /** * @return {?} */ function () { this.ps = new PerfectScrollbar(this._elementRef.nativeElement, {}); }; /** * @return {?} */ PerfectScrollbarDirective.prototype.ngOnDestroy = /** * @return {?} */ function () { this.ps && this.ps.destroy(); this.allSub.forEach((/** * @param {?} x * @return {?} */ function (x) { return x.unsubscribe(); })); }; PerfectScrollbarDirective.decorators = [ { type: Directive, args: [{ selector: '[addapptablesPerfectScrollbar]' },] } ]; /** @nocollapse */ PerfectScrollbarDirective.ctorParameters = function () { return [ { type: ElementRef }, { type: Router } ]; }; PerfectScrollbarDirective.propDecorators = { perfectScrollOptions: [{ type: Input }], onResize: [{ type: HostListener, args: ['window:resize',] }] }; return PerfectScrollbarDirective; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var AddapptablePerfectScrollbarModule = /** @class */ (function () { function AddapptablePerfectScrollbarModule() { } AddapptablePerfectScrollbarModule.decorators = [ { type: NgModule, args: [{ declarations: [ PerfectScrollbarDirective ], exports: [ PerfectScrollbarDirective ] },] } ]; return AddapptablePerfectScrollbarModule; }()); export { AddapptablePerfectScrollbarModule, PerfectScrollbarDirective }; //# sourceMappingURL=addapptables-perfect-scrollbar.js.map