es-grid-template
Version:
es-grid-template
37 lines (36 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* During table cell rendering, the colSpan/rowSpan of previously rendered cells
* affects whether subsequent cells should be rendered.
*
* `SpanManager` internally maintains a state that records the colSpan/rowSpan
* of the most recently rendered cells, allowing subsequent cells to quickly
* determine whether they should skip rendering.
*/
class SpanManager {
rects = [];
testSkip(rowIndex, colIndex) {
return this.rects.some(({
left,
right,
top,
bottom
}) => left <= colIndex && colIndex < right && top <= rowIndex && rowIndex < bottom);
}
stripUpwards(rowIndex) {
this.rects = this.rects.filter(rect => rect.bottom > rowIndex);
}
add(rowIndex, colIndex, colSpan, rowSpan) {
this.rects.push({
left: colIndex,
right: colIndex + colSpan,
top: rowIndex,
bottom: rowIndex + rowSpan
});
}
}
exports.default = SpanManager;