(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('primeng/api'), require('@angular/cdk/scrolling')) : typeof define === 'function' && define.amd ? define('primeng/virtualscroller', ['exports', '@angular/core', '@angular/common', 'primeng/api', '@angular/cdk/scrolling'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.primeng = global.primeng || {}, global.primeng.virtualscroller = {}), global.ng.core, global.ng.common, global.primeng.api, global.ng.cdk.scrolling)); }(this, (function (exports, core, common, api, scrolling) { 'use strict'; var VirtualScroller = /** @class */ (function () { function VirtualScroller(el) { this.el = el; this.trackBy = function (index, item) { return item; }; this.onLazyLoad = new core.EventEmitter(); this._totalRecords = 0; this.page = 0; this._first = 0; this.loadedPages = []; } Object.defineProperty(VirtualScroller.prototype, "totalRecords", { get: function () { return this._totalRecords; }, set: function (val) { this._totalRecords = val; console.log("totalRecords is deprecated, provide a value with the length of virtual items instead."); }, enumerable: false, configurable: true }); Object.defineProperty(VirtualScroller.prototype, "first", { get: function () { return this._first; }, set: function (val) { this._first = val; console.log("first property is deprecated, use scrollToIndex function to scroll a specific item."); }, enumerable: false, configurable: true }); Object.defineProperty(VirtualScroller.prototype, "cache", { get: function () { return this._cache; }, set: function (val) { this._cache = val; console.log("cache is deprecated as it is always on."); }, enumerable: false, configurable: true }); VirtualScroller.prototype.ngAfterContentInit = function () { var _this = this; this.templates.forEach(function (item) { switch (item.getType()) { case 'item': _this.itemTemplate = item.template; break; case 'loadingItem': _this.loadingItemTemplate = item.template; break; case 'header': _this.headerTemplate = item.template; break; case 'footer': _this.footerTemplate = item.template; break; default: _this.itemTemplate = item.template; break; } }); }; VirtualScroller.prototype.onScrollIndexChange = function (index) { var _this = this; if (this.lazy) { var pageRange = this.createPageRange(Math.floor(index / this.rows)); pageRange.forEach(function (page) { return _this.loadPage(page); }); } }; VirtualScroller.prototype.createPageRange = function (page) { var range = []; if (page !== 0) { range.push(page - 1); } range.push(page); if (page !== (Math.ceil(this.value.length / this.rows) - 1)) { range.push(page + 1); } return range; }; VirtualScroller.prototype.loadPage = function (page) { if (!this.loadedPages.includes(page)) { this.onLazyLoad.emit({ first: this.rows * page, rows: this.rows }); this.loadedPages.push(page); } }; VirtualScroller.prototype.getBlockableElement = function () { return this.el.nativeElement.children[0]; }; //@deprecated VirtualScroller.prototype.scrollTo = function (index, mode) { this.scrollToIndex(index, mode); }; VirtualScroller.prototype.scrollToIndex = function (index, mode) { if (this.viewport) { this.viewport.scrollToIndex(index, mode); } }; VirtualScroller.prototype.clearCache = function () { this.loadedPages = []; }; VirtualScroller.prototype.ngOnChanges = function (simpleChange) { if (simpleChange.value) { if (!this.lazy) { this.clearCache(); } } }; return VirtualScroller; }()); VirtualScroller.decorators = [ { type: core.Component, args: [{ selector: 'p-virtualScroller', template: "\n