Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(frozen bug): fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tubiaoge committed Aug 7, 2020
1 parent 7cfd0d9 commit 91daa07
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 27 deletions.
37 changes: 32 additions & 5 deletions src/controllers/freezen.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,51 @@ const luckysheetFreezen = {
}

if (_this.freezenverticaldata != null) {
let freezen_colindex = _this.freezenverticaldata[1];
let freezen_colindex = _this.freezenverticaldata[1];

let offset = luckysheet_searcharray(_this.freezenverticaldata[3], $("#luckysheet-cell-main").scrollLeft());

let top = _this.freezenverticaldata[4];

freezen_colindex += offset;

if(column>=Store.visibledatacolumn.length){
column = Store.visibledatacolumn.length - 1;
}

if(freezen_colindex>=Store.visibledatacolumn.length){
freezen_colindex = Store.visibledatacolumn.length - 1;
}

if (column <= freezen_colindex) {
setTimeout(function () { $("#luckysheet-scrollbar-x").scrollLeft(0); }, 10);
let column_px = Store.visibledatacolumn[column], freezen_px = Store.visibledatacolumn[freezen_colindex];

if (column_px <= freezen_px+top) {
console.log(1111);
setTimeout(function () { $("#luckysheet-scrollbar-x").scrollLeft(0); }, 100);
}
}

if (_this.freezenhorizontaldata != null) {
let freezen_rowindex = _this.freezenhorizontaldata[1];

let offset = luckysheet_searcharray(_this.freezenhorizontaldata[3], $("#luckysheet-cell-main").scrollTop());

let left = _this.freezenhorizontaldata[4];

freezen_rowindex += offset;

if (row <= freezen_rowindex) {
setTimeout(function () { $("#luckysheet-scrollbar-y").scrollTop(0); }, 10);
if(row>=Store.visibledatarow.length){
row = Store.visibledatarow.length - 1;
}

if(freezen_rowindex>=Store.visibledatarow.length){
freezen_rowindex = Store.visibledatarow.length - 1;
}

let row_px = Store.visibledatarow[row], freezen_px = Store.visibledatarow[freezen_rowindex];

if (row_px <= freezen_px+left) {
setTimeout(function () {$("#luckysheet-scrollbar-y").scrollTop(0);}, 100);
}
}
},
Expand Down
43 changes: 23 additions & 20 deletions src/global/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {
if (dataset_row_ed == -1) {
dataset_row_ed = Store.visibledatarow.length - 1;
}


luckysheetTableContent.save();
luckysheetTableContent.beginPath();
luckysheetTableContent.rect(0, offsetTop* Store.devicePixelRatio, Store.rowHeaderWidth * Store.devicePixelRatio-1, drawHeight-2);
luckysheetTableContent.rect(0, offsetTop* Store.devicePixelRatio, Store.rowHeaderWidth * Store.devicePixelRatio-1, drawHeight* Store.devicePixelRatio-2);
luckysheetTableContent.clip();

let end_r, start_r;
Expand All @@ -69,9 +70,9 @@ function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {
end_r = Store.visibledatarow[r] - scrollHeight;

//若超出绘制区域终止
if(end_r > scrollHeight + drawHeight){
break;
}
// if(end_r > scrollHeight + drawHeight){
// break;
// }

if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {

Expand Down Expand Up @@ -99,19 +100,19 @@ function luckysheetDrawgridRowTitle(scrollHeight, drawHeight, offsetTop) {

//vertical
luckysheetTableContent.beginPath();
luckysheetTableContent.moveTo(
(Store.rowHeaderWidth - 2 + 0.5) * Store.devicePixelRatio,
Store.devicePixelRatio * (start_r + offsetTop - 2)
);
luckysheetTableContent.lineTo(
(Store.rowHeaderWidth - 2 + 0.5) * Store.devicePixelRatio,
Store.devicePixelRatio * (end_r + offsetTop - 2)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;
luckysheetTableContent.moveTo(
(Store.rowHeaderWidth - 2 + 0.5) * Store.devicePixelRatio,
Store.devicePixelRatio * (start_r + offsetTop - 2)
);
luckysheetTableContent.lineTo(
(Store.rowHeaderWidth - 2 + 0.5) * Store.devicePixelRatio,
Store.devicePixelRatio * (end_r + offsetTop - 2)
);
luckysheetTableContent.lineWidth = Store.devicePixelRatio;

luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
luckysheetTableContent.stroke();
luckysheetTableContent.closePath();
luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
luckysheetTableContent.stroke();
luckysheetTableContent.closePath();

//行标题栏横线,horizen
luckysheetTableContent.beginPath();
Expand Down Expand Up @@ -190,9 +191,11 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {

luckysheetTableContent.save();
luckysheetTableContent.beginPath();
luckysheetTableContent.rect(offsetLeft* Store.devicePixelRatio, 0, drawWidth, Store.columeHeaderHeight * Store.devicePixelRatio-1);
luckysheetTableContent.rect(offsetLeft* Store.devicePixelRatio, 0, drawWidth* Store.devicePixelRatio, Store.columeHeaderHeight * Store.devicePixelRatio-1);
luckysheetTableContent.clip();

// console.log(offsetLeft* Store.devicePixelRatio, 0, drawWidth* Store.devicePixelRatio, Store.columeHeaderHeight * Store.devicePixelRatio-1);

let end_c, start_c;

for (let c = dataset_col_st; c <= dataset_col_ed; c++) {
Expand All @@ -205,9 +208,9 @@ function luckysheetDrawgridColumnTitle(scrollWidth, drawWidth, offsetLeft) {
end_c = Store.visibledatacolumn[c] - scrollWidth;

//若超出绘制区域终止
if(end_c > scrollWidth + drawWidth){
break;
}
// if(end_c > scrollWidth + drawWidth+1){
// break;
// }

luckysheetTableContent.fillStyle = "#ffffff";
luckysheetTableContent.fillRect(
Expand Down
8 changes: 6 additions & 2 deletions src/global/refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,13 +964,17 @@ function luckysheetrefreshgrid(scrollWidth, scrollHeight) {
if($("#luckysheetTableContent").length == 0){
return;
}

let luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d");
luckysheetDrawMain(scrollWidth, scrollHeight);

$("#luckysheetTableContent").get(0).getContext("2d").clearRect(0, 0, 46, 20);
luckysheetTableContent.clearRect(0, 0, 46, 20);

luckysheetDrawgridColumnTitle(scrollWidth);
luckysheetDrawgridRowTitle(scrollHeight);

//清除canvas左上角区域 防止列标题栏序列号溢出显示

luckysheetTableContent.clearRect(0, 0, Store.rowHeaderWidth * Store.devicePixelRatio, Store.columeHeaderHeight * Store.devicePixelRatio);
}
}

Expand Down

0 comments on commit 91daa07

Please sign in to comment.