Fixed some render bugs

This commit is contained in:
Eugene 2023-07-27 11:54:06 +03:00
parent ca67d409d5
commit 8aed4c81b9
4 changed files with 16 additions and 7 deletions

View File

@ -66,6 +66,7 @@ export class Editor {
});
this.hide();
this.root.renderSelection()
}
}
};

View File

@ -52,7 +52,7 @@ export class Sheet {
this.root.data[row][column].render(this.root);
}
getSelectionRange() {
private getSelectionRange() {
const { selectedCell, selectedRange } = this.root.selection
if (!selectedCell && !selectedRange) return;
@ -85,7 +85,7 @@ export class Sheet {
}
}
renderSelectionRange(x: number, y: number, width: number, height: number) {
private renderSelectionRange(x: number, y: number, width: number, height: number) {
this.ctx.save()
this.ctx.strokeStyle = '#47d1ff'
@ -97,6 +97,13 @@ export class Sheet {
}
renderSelection() {
const box = this.getSelectionRange()
if (!box) return;
const {height, width, x, y} = box
this.renderSelectionRange(x, y, width, height)
}
renderSheet() {
const firstRowIdx = this.root.viewport.firstRow;
const lastColIdx = this.root.viewport.lastCol + 3;
@ -112,10 +119,7 @@ export class Sheet {
this.renderCell({ column: col, row });
}
}
this.renderSelection()
const box = this.getSelectionRange()
if (!box) return;
const {height, width, x, y} = box
this.renderSelectionRange(x, y, width, height)
}
}

View File

@ -315,6 +315,10 @@ export default class Spreadsheet {
this.sheet.renderSheet();
}
renderSelection() {
this.sheet.renderSelection();
}
renderColumnsBar() {
this.columnsBar.renderBar();
}

View File

@ -77,7 +77,7 @@ export class Clipboard {
} catch (err) {
console.error("Cannot read clipboard. ", err);
}
root.renderSheet()
return;
}