UNPKG

primeng

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primeng.svg)](https://badge.fury.io/js/primeng) [![Discord](https://img.shields.io/discord/557940238991753

2 lines 5.24 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(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"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).primeng=e.primeng||{},e.primeng.virtualscroller={}),e.ng.core,e.ng.common,e.primeng.api,e.ng.cdk.scrolling)}(this,(function(e,t,n,r,o){"use strict";var l=function(){function e(e){this.el=e,this.delay=250,this.trackBy=function(e,t){return t},this.onLazyLoad=new t.EventEmitter,this._totalRecords=0,this.page=0,this._first=0}return Object.defineProperty(e.prototype,"totalRecords",{get:function(){return this._totalRecords},set:function(e){this._totalRecords=e,console.log("totalRecords is deprecated, provide a value with the length of virtual items instead.")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"first",{get:function(){return this._first},set:function(e){this._first=e,console.log("first property is deprecated, use scrollToIndex function to scroll a specific item.")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return this._cache},set:function(e){this._cache=e,console.log("cache is deprecated as it is always on.")},enumerable:!1,configurable:!0}),e.prototype.ngAfterContentInit=function(){var e=this;this.templates.forEach((function(t){switch(t.getType()){case"item":e.itemTemplate=t.template;break;case"loadingItem":e.loadingItemTemplate=t.template;break;case"header":e.headerTemplate=t.template;break;case"footer":e.footerTemplate=t.template;break;default:e.itemTemplate=t.template}}))},e.prototype.onScrollIndexChange=function(e){var t=this;this.lazy&&(this.virtualScrollTimeout&&clearTimeout(this.virtualScrollTimeout),this.virtualScrollTimeout=setTimeout((function(){var n=Math.floor(e/t.rows),r=0===n?0:(n-1)*t.rows,o=0===n?2*t.rows:3*t.rows;n!==t.virtualPage&&(t.virtualPage=n,t.onLazyLoad.emit({first:r,rows:o}))}),this.delay))},e.prototype.getBlockableElement=function(){return this.el.nativeElement.children[0]},e.prototype.scrollTo=function(e,t){this.scrollToIndex(e,t)},e.prototype.scrollToIndex=function(e,t){this.viewport&&this.viewport.scrollToIndex(e,t)},e}();l.decorators=[{type:t.Component,args:[{selector:"p-virtualScroller",template:'\n <div [ngClass]="\'p-virtualscroller p-component\'" [ngStyle]="style" [class]="styleClass">\n <div class="p-virtualscroller-header" *ngIf="header || headerTemplate">\n <ng-content select="p-header"></ng-content>\n <ng-container *ngTemplateOutlet="headerTemplate"></ng-container>\n </div>\n <div #content class="p-virtualscroller-content">\n <div class="p-virtualscroller-list">\n <cdk-virtual-scroll-viewport #viewport [ngStyle]="{\'height\': scrollHeight}" tabindex="0" [itemSize]="itemSize" [minBufferPx]="minBufferPx" [maxBufferPx]="maxBufferPx" (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 <div [ngStyle]="{\'height\': itemSize + \'px\'}" class="p-virtualscroller-item">\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 </div>\n </ng-container>\n </cdk-virtual-scroll-viewport>\n </div>\n </div>\n <div class="p-virtualscroller-footer" *ngIf="footer || footerTemplate">\n <ng-content select="p-footer"></ng-content>\n <ng-container *ngTemplateOutlet="footerTemplate"></ng-container>\n </div>\n </div>\n ',changeDetection:t.ChangeDetectionStrategy.Default,encapsulation:t.ViewEncapsulation.None,styles:["cdk-virtual-scroll-viewport{outline:0 none}"]}]}],l.ctorParameters=function(){return[{type:t.ElementRef}]},l.propDecorators={value:[{type:t.Input}],itemSize:[{type:t.Input}],style:[{type:t.Input}],styleClass:[{type:t.Input}],scrollHeight:[{type:t.Input}],lazy:[{type:t.Input}],rows:[{type:t.Input}],minBufferPx:[{type:t.Input}],maxBufferPx:[{type:t.Input}],delay:[{type:t.Input}],trackBy:[{type:t.Input}],header:[{type:t.ContentChild,args:[r.Header]}],footer:[{type:t.ContentChild,args:[r.Footer]}],templates:[{type:t.ContentChildren,args:[r.PrimeTemplate]}],viewport:[{type:t.ViewChild,args:[o.CdkVirtualScrollViewport]}],onLazyLoad:[{type:t.Output}],totalRecords:[{type:t.Input}],first:[{type:t.Input}],cache:[{type:t.Input}]};var i=function(){};i.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule,o.ScrollingModule],exports:[l,r.SharedModule,o.ScrollingModule],declarations:[l]}]}],e.VirtualScroller=l,e.VirtualScrollerModule=i,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=primeng-virtualscroller.umd.min.js.map