UNPKG

@visactor/vtable

Version:

canvas table width high performance

48 lines (42 loc) 3.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.updateAutoRow = void 0; const vutils_1 = require("@visactor/vutils"); function updateAutoRow(colStart, colEnd, rowStart, rowEnd, table, direction = "up", part) { var _a, _b; if ("up" === direction) for (let col = colStart; col <= colEnd; col++) for (let row = rowStart; row <= rowEnd; row++) { const cellGroup = table.scenegraph.highPerformanceGetCell(col, row, !0); if ("cell" !== cellGroup.role || !cellGroup.row) continue; let y; if (cellGroup._prev) y = (null === (_a = cellGroup._prev) || void 0 === _a ? void 0 : _a.attribute.y) + table.getRowHeight(cellGroup._prev.row); else if (part) { const baseRowIndex = rowEnd === table.rowCount - table.bottomFrozenRowCount - 1 ? rowEnd : rowEnd + 1; if (y = table.scenegraph.highPerformanceGetCell(col, baseRowIndex, !0).attribute.y, (0, vutils_1.isValid)(y)) for (let r = row; r < baseRowIndex; r++) y -= table.getRowHeight(r); } else y = getEstimatePosition(cellGroup.row, table); (0, vutils_1.isValid)(y) && cellGroup.setAttribute("y", y); } else for (let col = colStart; col <= colEnd; col++) for (let row = rowEnd; row >= rowStart; row--) { const cellGroup = table.scenegraph.highPerformanceGetCell(col, row, !0); if ("cell" !== cellGroup.role || !cellGroup.row) continue; let y; if (cellGroup._next) y = (null === (_b = cellGroup._next) || void 0 === _b ? void 0 : _b.attribute.y) - table.getRowHeight(cellGroup.row); else if (part) { const baseRowIndex = rowStart <= table.frozenRowCount ? table.frozenRowCount : rowStart - 1; if (rowStart <= table.frozenRowCount) y = 0; else { y = table.scenegraph.highPerformanceGetCell(col, baseRowIndex, !0).attribute.y; } for (let r = baseRowIndex; r < row; r++) { y += table.getRowHeight(r); } } else y = getEstimatePosition(cellGroup.row, table); (0, vutils_1.isValid)(y) && cellGroup.setAttribute("y", y); } const totalActualBodyRowCount = Math.min(table.scenegraph.proxy.rowLimit, table.scenegraph.proxy.bodyBottomRow - table.scenegraph.proxy.bodyTopRow + 1), totalBodyHeight = table.getRowsHeight(table.frozenRowCount, table.frozenRowCount + totalActualBodyRowCount), totalHeight = table.getRowsHeight(table.frozenRowCount, table.rowCount - 1); table.scenegraph.proxy.yLimitTop = totalBodyHeight / 2, table.scenegraph.proxy.yLimitBottom = totalHeight - totalBodyHeight / 2; } function getEstimatePosition(row, table) { let y; return y = row < table.frozenRowCount ? table.getRowsHeight(0, row - 1) : row >= table.rowCount - table.bottomFrozenRowCount ? table.getRowsHeight(table.rowCount - table.bottomFrozenRowCount, row - 1) : table.getRowsHeight(table.frozenRowCount, row - 1), y; } exports.updateAutoRow = updateAutoRow; //# sourceMappingURL=update-auto-row.js.map