UNPKG

5.65 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("primeng/api"),require("@angular/cdk/scrolling")):"function"==typeof define&&define.amd?define("primeng/virtualscroller",["exports","@angular/core","@angular/common","primeng/api","@angular/cdk/scrolling"],e):e(((t=t||self).primeng=t.primeng||{},t.primeng.virtualscroller={}),t.ng.core,t.ng.common,t.primeng.api,t.ng.cdk.scrolling)}(this,(function(t,e,o,r,i){"use strict";var n=this&&this.__decorate||function(t,e,o,r){var i,n=arguments.length,l=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,e,o,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(l=(n<3?i(l):n>3?i(e,o,l):i(e,o))||l);return n>3&&l&&Object.defineProperty(e,o,l),l},l=this&&this.__read||function(t,e){var o="function"==typeof Symbol&&t[Symbol.iterator];if(!o)return t;var r,i,n=o.call(t),l=[];try{for(;(void 0===e||e-- >0)&&!(r=n.next()).done;)l.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(i)throw i.error}}return l},a=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(l(arguments[e]));return t},s=function(){function t(t){this.el=t,this.cache=!0,this.first=0,this.trackBy=function(t,e){return e},this.onLazyLoad=new e.EventEmitter,this._totalRecords=0,this.lazyValue=[],this.page=0}return Object.defineProperty(t.prototype,"totalRecords",{get:function(){return this._totalRecords},set:function(t){this._totalRecords=t,this.lazyValue=Array.from({length:this._totalRecords}),this.onLazyLoad.emit(this.createLazyLoadMetadata()),this.first=0,this.scrollTo(0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this.lazy?this.lazyValue:this._value},set:function(t){if(this.lazy){if(t){for(var e=this.cache?a(this.lazyValue):Array.from({length:this._totalRecords}),o=this.first,r=0;o<this.first+this.rows;o++,r++)e[o]=t[r];this.lazyValue=e}}else this._value=t},enumerable:!0,configurable:!0}),t.prototype.ngAfterContentInit=function(){var t=this;this.templates.forEach((function(e){switch(e.getType()){case"item":t.itemTemplate=e.template;break;case"loadingItem":t.loadingItemTemplate=e.template;break;default:t.itemTemplate=e.template}}))},t.prototype.onScrollIndexChange=function(t){var e=Math.floor(t/this.rows);e!==this.page&&(this.page=e,this.first=this.page*this.rows,this.onLazyLoad.emit(this.createLazyLoadMetadata()))},t.prototype.createLazyLoadMetadata=function(){return{first:this.first,rows:this.rows}},t.prototype.getBlockableElement=function(){return this.el.nativeElement.children[0]},t.prototype.scrollTo=function(t){this.viewPortViewChild&&this.viewPortViewChild.elementRef&&this.viewPortViewChild.elementRef.nativeElement&&(this.viewPortViewChild.elementRef.nativeElement.scrollTop=t*this.itemSize)},t.ctorParameters=function(){return[{type:e.ElementRef}]},n([e.Input()],t.prototype,"itemSize",void 0),n([e.Input()],t.prototype,"style",void 0),n([e.Input()],t.prototype,"styleClass",void 0),n([e.Input()],t.prototype,"scrollHeight",void 0),n([e.Input()],t.prototype,"lazy",void 0),n([e.Input()],t.prototype,"cache",void 0),n([e.Input()],t.prototype,"rows",void 0),n([e.Input()],t.prototype,"first",void 0),n([e.Input()],t.prototype,"trackBy",void 0),n([e.ContentChild(r.Header)],t.prototype,"header",void 0),n([e.ContentChild(r.Footer)],t.prototype,"footer",void 0),n([e.ContentChildren(r.PrimeTemplate)],t.prototype,"templates",void 0),n([e.ViewChild("viewport")],t.prototype,"viewPortViewChild",void 0),n([e.Output()],t.prototype,"onLazyLoad",void 0),n([e.Input()],t.prototype,"totalRecords",null),n([e.Input()],t.prototype,"value",null),t=n([e.Component({selector:"p-virtualScroller",template:'\n <div [ngClass]="\'ui-virtualscroller ui-widget\'" [ngStyle]="style" [class]="styleClass">\n <div class="ui-virtualscroller-header ui-widget-header ui-corner-top" *ngIf="header">\n <ng-content select="p-header"></ng-content>\n </div>\n <div #content class="ui-virtualscroller-content ui-widget-content">\n <ul class="ui-virtualscroller-list">\n <cdk-virtual-scroll-viewport #viewport [ngStyle]="{\'height\': scrollHeight}" [itemSize]="itemSize" (scrolledIndexChange)="onScrollIndexChange($event)">\n <ng-container *cdkVirtualFor="let item of value; trackBy: trackBy; let i = index; let c = count; let f = first; let l = last; let e = even; let o = odd; ">\n <li [ngStyle]="{\'height\': itemSize + \'px\'}">\n <ng-container *ngTemplateOutlet="item ? itemTemplate : loadingItemTemplate; context: {$implicit: item, index: i, count: c, first: f, last: l, even: e, odd: o}"></ng-container>\n </li>\n </ng-container>\n </cdk-virtual-scroll-viewport>\n </ul>\n </div>\n <div class="ui-virtualscroller-footer ui-widget-header ui-corner-bottom" *ngIf="footer">\n <ng-content select="p-footer"></ng-content>\n </div>\n </div>\n ',changeDetection:e.ChangeDetectionStrategy.Default})],t)}(),c=function(){function t(){}return t=n([e.NgModule({imports:[o.CommonModule,i.ScrollingModule],exports:[s,r.SharedModule,i.ScrollingModule],declarations:[s]})],t)}();t.VirtualScroller=s,t.VirtualScrollerModule=c,Object.defineProperty(t,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-virtualscroller.umd.min.js.map
\No newline at end of file