(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.delay = 250; this.trackBy = function (index, item) { return item; }; this.onLazyLoad = new core.EventEmitter(); this._totalRecords = 0; this.page = 0; this._first = 0; } 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) { if (this.virtualScrollTimeout) { clearTimeout(this.virtualScrollTimeout); } this.virtualScrollTimeout = setTimeout(function () { var page = Math.floor(index / _this.rows); var virtualScrollOffset = page === 0 ? 0 : (page - 1) * _this.rows; var virtualScrollChunkSize = page === 0 ? _this.rows * 2 : _this.rows * 3; if (page !== _this.virtualPage) { _this.virtualPage = page; _this.onLazyLoad.emit({ first: virtualScrollOffset, rows: virtualScrollChunkSize }); } }, this.delay); } }; 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); } }; return VirtualScroller; }()); VirtualScroller.decorators = [ { type: core.Component, args: [{ selector: 'p-virtualScroller', template: "\n