{"version":3,"file":"primeng-virtualscroller.umd.js","sources":["../../src/app/components/virtualscroller/virtualscroller.ts","../../src/app/components/virtualscroller/primeng-virtualscroller.ts"],"sourcesContent":["import {NgModule,Component,ElementRef,AfterContentInit,Input,Output,ViewChild,EventEmitter,ContentChild,ContentChildren,QueryList,TemplateRef,ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';\nimport {CommonModule} from '@angular/common';\nimport {Header,Footer,PrimeTemplate,SharedModule} from 'primeng/api';\nimport {ScrollingModule,CdkVirtualScrollViewport} from '@angular/cdk/scrolling';\nimport {BlockableUI} from 'primeng/api';\n\n@Component({\n selector: 'p-virtualScroller',\n template:`\n
\n
\n \n \n
\n
\n
\n \n \n
\n \n
\n
\n
\n
\n
\n
\n \n \n
\n
\n `,\n changeDetection: ChangeDetectionStrategy.Default,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./virtualscroller.css']\n})\nexport class VirtualScroller implements AfterContentInit,BlockableUI {\n\n @Input() value: any[];\n\n @Input() itemSize: number; \n\n @Input() style: any;\n\n @Input() styleClass: string;\n \n @Input() scrollHeight: any;\n\n @Input() lazy: boolean;\n\n @Input() rows: number;\n\n @Input() minBufferPx: number;\n\n @Input() maxBufferPx: number;\n\n @Input() delay: number = 250;\n \n @Input() trackBy: Function = (index: number, item: any) => item;\n \n @ContentChild(Header) header: Header;\n\n @ContentChild(Footer) footer: Footer;\n \n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n @ViewChild(CdkVirtualScrollViewport) viewport: CdkVirtualScrollViewport;\n\n @Output() onLazyLoad: EventEmitter = new EventEmitter();\n\n itemTemplate: TemplateRef;\n\n headerTemplate: TemplateRef;\n\n footerTemplate: TemplateRef;\n\n loadingItemTemplate: TemplateRef;\n\n _totalRecords: number = 0;\n\n page: number = 0;\n\n _first: number = 0;\n\n _cache: boolean;\n\n virtualScrollTimeout: any;\n\n virtualPage: number;\n\n constructor(public el: ElementRef) {}\n\n @Input() get totalRecords(): number {\n return this._totalRecords;\n }\n set totalRecords(val: number) {\n this._totalRecords = val;\n console.log(\"totalRecords is deprecated, provide a value with the length of virtual items instead.\");\n }\n\n @Input() get first(): number {\n return this._first;\n }\n set first(val:number) {\n this._first = val;\n console.log(\"first property is deprecated, use scrollToIndex function to scroll a specific item.\");\n }\n\n @Input() get cache(): boolean {\n return this._cache;\n }\n set cache(val: boolean) {\n this._cache = val;\n console.log(\"cache is deprecated as it is always on.\");\n }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch(item.getType()) {\n case 'item':\n this.itemTemplate = item.template;\n break;\n\n case 'loadingItem':\n this.loadingItemTemplate = item.template;\n break;\n\n case 'header':\n this.headerTemplate = item.template;\n break;\n\n case 'footer':\n this.footerTemplate = item.template;\n break;\n \n default:\n this.itemTemplate = item.template;\n break;\n }\n });\n }\n\n onScrollIndexChange(index: number) {\n if (this.lazy) {\n if (this.virtualScrollTimeout) {\n clearTimeout(this.virtualScrollTimeout);\n }\n\n this.virtualScrollTimeout = setTimeout(() => {\n let page = Math.floor(index / this.rows);\n let virtualScrollOffset = page === 0 ? 0 : (page - 1) * this.rows;\n let virtualScrollChunkSize = page === 0 ? this.rows * 2 : this.rows * 3;\n \n if (page !== this.virtualPage) {\n this.virtualPage = page;\n this.onLazyLoad.emit({first: virtualScrollOffset, rows: virtualScrollChunkSize});\n }\n }, this.delay);\n }\n }\n\n getBlockableElement(): HTMLElement {\n return this.el.nativeElement.children[0];\n }\n\n //@deprecated\n scrollTo(index: number, mode?: ScrollBehavior): void {\n this.scrollToIndex(index, mode);\n }\n\n scrollToIndex(index: number, mode?: ScrollBehavior): void {\n if (this.viewport) {\n this.viewport.scrollToIndex(index, mode);\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule,ScrollingModule],\n exports: [VirtualScroller,SharedModule,ScrollingModule],\n declarations: [VirtualScroller]\n})\nexport class VirtualScrollerModule { }\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["EventEmitter","Component","ChangeDetectionStrategy","ViewEncapsulation","ElementRef","Input","ContentChild","Header","Footer","ContentChildren","PrimeTemplate","ViewChild","CdkVirtualScrollViewport","Output","NgModule","CommonModule","ScrollingModule","SharedModule"],"mappings":";;;;;;;QAyFI,yBAAmB,EAAc;YAAd,OAAE,GAAF,EAAE,CAAY;YAlCxB,UAAK,GAAW,GAAG,CAAC;YAEpB,YAAO,GAAa,UAAC,KAAa,EAAE,IAAS,IAAK,OAAA,IAAI,GAAA,CAAC;YAUtD,eAAU,GAAsB,IAAIA,iBAAY,EAAE,CAAC;YAU7D,kBAAa,GAAW,CAAC,CAAC;YAE1B,SAAI,GAAW,CAAC,CAAC;YAEjB,WAAM,GAAW,CAAC,CAAC;SAQkB;QAErC,sBAAa,yCAAY;iBAAzB;gBACI,OAAO,IAAI,CAAC,aAAa,CAAC;aAC7B;iBACD,UAAiB,GAAW;gBACxB,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC;gBACzB,OAAO,CAAC,GAAG,CAAC,uFAAuF,CAAC,CAAC;aACxG;;;WAJA;QAMD,sBAAa,kCAAK;iBAAlB;gBACI,OAAO,IAAI,CAAC,MAAM,CAAC;aACtB;iBACD,UAAU,GAAU;gBAChB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,qFAAqF,CAAC,CAAC;aACtG;;;WAJA;QAMD,sBAAa,kCAAK;iBAAlB;gBACI,OAAO,IAAI,CAAC,MAAM,CAAC;aACtB;iBACD,UAAU,GAAY;gBAClB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;aAC1D;;;WAJA;QAMD,4CAAkB,GAAlB;YAAA,iBAwBC;YAvBG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAC,IAAI;gBACxB,QAAO,IAAI,CAAC,OAAO,EAAE;oBACjB,KAAK,MAAM;wBACP,KAAI,CAAC,YAAY,GAAG,IAAI,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