Fixed bugs in Chrome browser

Fixed on load data config listeners reassigning
This commit is contained in:
Eugene 2023-07-27 15:54:36 +03:00
parent cddfc134f8
commit c26c166295
3 changed files with 16 additions and 11 deletions

View File

@ -103,10 +103,10 @@ export class Sheet {
height: number, height: number,
) { ) {
this.ctx.save(); this.ctx.save();
this.ctx.strokeStyle = "#47d1ff"; this.ctx.strokeStyle = "#7da8ff";
this.ctx.lineWidth = 3; this.ctx.lineWidth = 3;
this.ctx.strokeRect(x, y, width, height); this.ctx.strokeRect(x, y, width, height);
this.ctx.fillStyle = "#7da8ff50"; this.ctx.fillStyle = "#7da8ff35";
this.ctx.fillRect(x, y, width, height); this.ctx.fillRect(x, y, width, height);
this.ctx.restore(); this.ctx.restore();
} }
@ -124,6 +124,7 @@ export class Sheet {
const lastRowIdx = this.root.viewport.lastRow + 3; const lastRowIdx = this.root.viewport.lastRow + 3;
const firstColIdx = this.root.viewport.firstCol; const firstColIdx = this.root.viewport.firstCol;
for (let row = firstRowIdx; row <= lastRowIdx; row++) { for (let row = firstRowIdx; row <= lastRowIdx; row++) {
for (let col = firstColIdx; col <= lastColIdx; col++) { for (let col = firstColIdx; col <= lastColIdx; col++) {
if (!this.root.config.columns[col] || !this.root.config.rows[row]) if (!this.root.config.columns[col] || !this.root.config.rows[row])

View File

@ -331,7 +331,6 @@ export default class Spreadsheet {
public loadData(data: Cell[][] | SerializableCell[][]): Spreadsheet { public loadData(data: Cell[][] | SerializableCell[][]): Spreadsheet {
const rowsLength = data.length; const rowsLength = data.length;
const colsLength = data[0] ? data[0].length : 0; const colsLength = data[0] ? data[0].length : 0;
console.log("!!FORMATTED DATA", rowsLength, colsLength, data[0])
this.data = []; this.data = [];
const formattedData: Cell[][] = []; const formattedData: Cell[][] = [];
@ -353,12 +352,17 @@ export default class Spreadsheet {
formattedData.push(innerRow); formattedData.push(innerRow);
} }
const config = this.makeConfigFromData(formattedData, this.config.view);
config.onCellChange = this.config.onCellChange
config.onCellClick = this.config.onCellClick
config.onCopy = this.config.onCopy
config.onSelectonChange = this.config.onSelectonChange
this.data = formattedData; this.data = formattedData;
this.selection.selectedCell = null; this.selection.selectedCell = null;
this.selection.selectedRange = null; this.selection.selectedRange = null;
this.config = this.makeConfigFromData(formattedData, this.config.view); this.config = config
this.cache = this.getInitialCache(); this.cache = this.getInitialCache();
this.scroller.updateScrollerSize(); this.scroller.updateScrollerSize();
this.viewport = new Viewport( this.viewport = new Viewport(

View File

@ -44,21 +44,21 @@ export class Cache {
public getRowByYCoord(y: number): number { public getRowByYCoord(y: number): number {
let rowIdx = 0; let rowIdx = 0;
for (let i = 0; i < this.rows.length; i++) { for (let i = 0; i < this.rows.length; i++) {
if (y <= this.rows[i].yPos) { rowIdx = i
//* Intersection detect if (y <= this.rows[i].yPos) { //* Intersection detect
rowIdx = i;
break; break;
} }
} }
return rowIdx; return rowIdx;
} }
public getColumnByXCoord(x: number): number { public getColumnByXCoord(x: number): number {
let colIdx = 0; let colIdx = 0;
for (let i = 0; i < this.columns.length; i++) { for (let i = 0; i < this.columns.length; i++) {
if (x <= this.columns[i].xPos) { colIdx = i
//* Intersection detect if (x <= this.columns[i].xPos) { //* Intersection detect
colIdx = i;
break; break;
} }
} }