Skip to content

Commit

Permalink
fix headers getheader size needs to be compensated by the scroll diff…
Browse files Browse the repository at this point in the history
… it s garbage since needs to take frozen pane in account but whatever
  • Loading branch information
rrahir committed Jan 1, 2025
1 parent bd5a9ed commit 79b8560
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/plugins/ui_stateful/sheetview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,12 @@ export class SheetViewPlugin extends UIPlugin {
referenceIndex: HeaderIndex,
index: HeaderIndex
): Pixel {
const sheetId = this.getters.getActiveSheetId();
const visibleCols = this.getters.getSheetViewVisibleCols();
const visibleRows = this.getters.getSheetViewVisibleRows();
if (index < referenceIndex) {
return -this.getColRowOffsetInViewport(dimension, index, referenceIndex);
}
const sheetId = this.getters.getActiveSheetId();
const visibleCols = this.getters.getSheetViewVisibleCols();
const visibleRows = this.getters.getSheetViewVisibleRows();
let offset = 0;
const visibleIndexes = dimension === "COL" ? visibleCols : visibleRows;
for (let i = referenceIndex; i < index; i++) {
Expand All @@ -436,6 +436,12 @@ export class SheetViewPlugin extends UIPlugin {
}
offset += this.getters.getHeaderSize(sheetId, dimension, i);
}
const viewport = this.getMainInternalViewport(sheetId);
if (dimension === "ROW") {
offset -= viewport.offsetScrollbarY - viewport.offsetY;
} else {
offset -= viewport.offsetScrollbarX - viewport.offsetX;
}
return offset;
}

Expand Down
6 changes: 6 additions & 0 deletions src/stores/grid_renderer_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ export class GridRenderer {
ctx.lineWidth = thinLineWidth;
ctx.strokeStyle = "#333";

// FIX the headers to account for the scrolloffset
// Columns headers background
for (let col = left; col <= right; col++) {
const colZone = { left: col, right: col, top: 0, bottom: numberOfRows - 1 };
Expand Down Expand Up @@ -471,6 +472,10 @@ export class GridRenderer {
}

ctx.stroke();

// cut that with the top left corner
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 0, HEADER_WIDTH, HEADER_HEIGHT);
}

private drawFrozenPanesHeaders(renderingContext: GridRenderingContext) {
Expand Down Expand Up @@ -744,6 +749,7 @@ export class GridRenderer {
const bottom = visibleRows[visibleRows.length - 1];
const viewport = { left, right, top, bottom };
const sheetId = this.getters.getActiveSheetId();
// TODO frozen pane don't work

for (const row of visibleRows) {
for (const col of visibleCols) {
Expand Down

0 comments on commit 79b8560

Please sign in to comment.