Skip to content

Commit

Permalink
fix: 修复存在滚动时 点击冻结首列 实际冻结的是当前视图第一列的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cdswyda committed Nov 11, 2021
1 parent d192b3c commit efb593b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
35 changes: 18 additions & 17 deletions src/controllers/menuButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { replaceHtml, getObjType, rgbTohex, mouseclickposition, luckysheetfontfo
import {openProtectionModal,checkProtectionFormatCells,checkProtectionNotEnable} from './protection';
import Store from '../store';
import locale from '../locale/locale';
import {checkTheStatusOfTheSelectedCells, frozenFirstRow} from '../global/api';
import { checkTheStatusOfTheSelectedCells, frozenFirstRow, frozenFirstColumn } from '../global/api';

const menuButton = {
"menu": '<div class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-menuButton ${subclass} luckysheet-mousedown-cancel" id="luckysheet-icon-${id}-menuButton">${item}</div>',
Expand Down Expand Up @@ -1645,24 +1645,25 @@ const menuButton = {
// luckysheetrefreshgrid();
}
else if(itemvalue == "freezenColumn"){ //首列冻结
let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
if(col_st == -1){
col_st = 0;
}
let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
let freezenverticaldata = [Store.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1), left];
luckysheetFreezen.saveFreezen(null, null, freezenverticaldata, left);
frozenFirstColumn();
// let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
// let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
// if(col_st == -1){
// col_st = 0;
// }
// let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
// let freezenverticaldata = [Store.visibledatacolumn[col_st], col_st + 1, scrollLeft, luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1), left];
// luckysheetFreezen.saveFreezen(null, null, freezenverticaldata, left);

if (luckysheetFreezen.freezenhorizontaldata != null) {
luckysheetFreezen.cancelFreezenHorizontal();
luckysheetFreezen.createAssistCanvas();
luckysheetrefreshgrid();
}
// if (luckysheetFreezen.freezenhorizontaldata != null) {
// luckysheetFreezen.cancelFreezenHorizontal();
// luckysheetFreezen.createAssistCanvas();
// luckysheetrefreshgrid();
// }

luckysheetFreezen.createFreezenVertical(freezenverticaldata, left);
luckysheetFreezen.createAssistCanvas();
luckysheetrefreshgrid();
// luckysheetFreezen.createFreezenVertical(freezenverticaldata, left);
// luckysheetFreezen.createAssistCanvas();
// luckysheetrefreshgrid();
}
else if(itemvalue == "freezenRC"){ //首行列冻结
let scrollTop = $("#luckysheet-cell-main").scrollTop();
Expand Down
16 changes: 9 additions & 7 deletions src/global/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,18 +651,20 @@ export function frozenFirstColumn(order) {

// 冻结为当前sheet页
if (!order || order == getSheetIndex(Store.currentSheetIndex)) {
let scrollLeft = $("#luckysheet-cell-main").scrollLeft();
// let scrollLeft = $("#luckysheet-cell-main").scrollLeft();

let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
if(col_st == -1){
col_st = 0;
}
// let col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollLeft);
// if(col_st == -1){
// col_st = 0;
// }
let col_st = 0;

let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
// let left = Store.visibledatacolumn[col_st] - 2 - scrollLeft + Store.rowHeaderWidth;
let left = Store.visibledatacolumn[col_st] - 2 + Store.rowHeaderWidth;
let freezenverticaldata = [
Store.visibledatacolumn[col_st],
col_st + 1,
scrollLeft,
0,
luckysheetFreezen.cutVolumn(Store.visibledatacolumn, col_st + 1),
left
];
Expand Down

0 comments on commit efb593b

Please sign in to comment.