all files / actions/ dom-virtualization.js

97.5% Statements 39/40
89.29% Branches 25/28
100% Functions 9/9
97.5% Lines 39/40
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 621×   1× 1× 1× 1× 34× 34×   1× 34× 1× 1×   34× 34×   1× 83× 1×   82×   82×   82×   82× 82× 82× 82×     82× 82× 82× 82× 82× 82×         1× 1×       1×   1× 64497×   1× 34× 18×   1×   1×    
define(["require", "exports", "@syncfusion/ej2-treegrid"], function (require, exports, ej2_treegrid_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var treeGridDomVirtInjected = false;
    var DomVirtualization = (function () {
        function DomVirtualization(gantt) {
            this.parent = gantt;
            this.addEventListener();
        }
        DomVirtualization.prototype.addEventListener = function () {
            if (!treeGridDomVirtInjected) {
                ej2_treegrid_1.TreeGrid.Inject(ej2_treegrid_1.DomVirtualization);
                treeGridDomVirtInjected = true;
            }
            this.parent.on('dataReady', this.onDataReady, this);
            this.parent.on('destroy', this.destroy, this);
        };
        DomVirtualization.prototype.getVisibleRecordsFromScroll = function (scrollTopOverride) {
            if (!this.parent.currentViewData || this.parent.currentViewData.length === 0) {
                return { records: [], startIndex: 0 };
            }
            var scrollElement = this.parent.ganttChartModule &&
                this.parent.ganttChartModule.scrollElement;
            var rawScrollTop = scrollTopOverride != null ? scrollTopOverride :
                (scrollElement ? scrollElement.scrollTop : 0);
            var viewportHeight = (scrollElement && scrollElement.clientHeight > 0)
                ? scrollElement.clientHeight : (window.innerHeight || 600);
            var rowHeight = this.parent.rowHeight || 36;
            var totalRows = this.parent.currentViewData.length;
            var maxScrollTop = Math.max(0, totalRows * rowHeight - viewportHeight);
            var scrollTop = scrollTopOverride != null
                ? rawScrollTop
                : Math.min(Math.max(0, rawScrollTop), maxScrollTop);
            var settings = this.parent.domVirtualizationSettings || {};
            var rowBuffer = settings.rowBuffer != null ? settings.rowBuffer : 20;
            var startIndex = Math.max(0, Math.floor(scrollTop / rowHeight) - rowBuffer);
            var visibleCount = this.parent.treeGrid['currentDomVirtualRecords'].length;
            var endIndex = Math.min(totalRows, startIndex + visibleCount);
            return {
                records: this.parent.currentViewData.slice(startIndex, endIndex),
                startIndex: startIndex
            };
        };
        DomVirtualization.prototype.refreshDomVirtualRows = function (records, startIndex) {
            Iif (this.parent.chartRowsModule) {
                this.parent.chartRowsModule.refreshDomVirtualRows(records, startIndex);
            }
        };
        DomVirtualization.prototype.onDataReady = function () {
        };
        DomVirtualization.prototype.getModuleName = function () {
            return 'domVirtualization';
        };
        DomVirtualization.prototype.destroy = function () {
            this.parent.off('dataReady', this.onDataReady);
            this.parent.off('destroy', this.destroy);
        };
        return DomVirtualization;
    }());
    exports.DomVirtualization = DomVirtualization;
});