@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
22 lines (21 loc) • 1.05 kB
JavaScript
import { boundSelectionRect } from "./bound-selection-rect.js";
import { adjustRectForRowAndCellSpan } from "./adjust-rect-for-row-and-cell-span.js";
import { areRectsEqual } from "./are-rects-equal.js";
import { splitCellSelectionRect } from "./split-cell-selection-rect.js";
export function updateAdditiveCellSelection(api, view, rowTopCount, rowCount, rowBottomCount, rect, cellSelectionAdditiveRects, setSelectionAdditiveRects) {
const s = view;
const adjustedRect = adjustRectForRowAndCellSpan(api.cellRoot, rect);
const rects = splitCellSelectionRect({
rect: boundSelectionRect(view, rowCount, adjustedRect),
colCenterCount: s.centerCount,
colStartCount: s.startCount,
rowCenterCount: rowCount - rowTopCount - rowBottomCount,
rowTopCount: rowTopCount,
});
const current = cellSelectionAdditiveRects;
if (current && current.length === rects.length) {
if (current.every((c, i) => areRectsEqual(c, rects[i])))
return;
}
setSelectionAdditiveRects(rects);
}