UNPKG

ngx-ui-scroll

Version:

Infinite/virtual scroll for Angular

43 lines 2.16 kB
import { Component, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { Workflow } from './vscroll'; import consumer from './ui-scroll.version'; var UiScrollComponent = /** @class */ (function () { function UiScrollComponent(changeDetector, elementRef) { this.changeDetector = changeDetector; this.elementRef = elementRef; // the only template variable this.items = []; } UiScrollComponent.prototype.ngOnInit = function () { var _this = this; this.workflow = new Workflow({ consumer: consumer, element: this.elementRef.nativeElement, datasource: this.datasource, run: function (items) { if (!items.length && !_this.items.length) { return; } _this.items = items; _this.changeDetector.detectChanges(); } }); }; UiScrollComponent.prototype.ngOnDestroy = function () { this.workflow.dispose(); }; UiScrollComponent.decorators = [ { type: Component, args: [{ selector: '[ui-scroll]', changeDetection: ChangeDetectionStrategy.OnPush, template: "\n <div data-padding-backward></div>\n <div\n *ngFor=\"let item of items\"\n [attr.data-sid]=\"item.$index\"\n [style.position]=\"item.invisible ? 'fixed' : null\"\n [style.left]=\"item.invisible ? '-99999px' : null\">\n <ng-template\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{\n $implicit: item.data,\n index: item.$index,\n odd: item.$index % 2,\n even: !(item.$index % 2)\n }\"></ng-template>\n </div>\n <div data-padding-forward></div>" },] } ]; UiScrollComponent.ctorParameters = function () { return [ { type: ChangeDetectorRef }, { type: ElementRef } ]; }; return UiScrollComponent; }()); export { UiScrollComponent }; //# sourceMappingURL=ui-scroll.component.js.map