diff --git a/src/controllers/resize.js b/src/controllers/resize.js index bc9e842..7db3593 100644 --- a/src/controllers/resize.js +++ b/src/controllers/resize.js @@ -63,7 +63,7 @@ export default function luckysheetsizeauto(isRefreshCanvas=true) { $("#" + Store.container).find(".luckysheet").height(gridH - 2).width(gridW - 2); - changeSheetContainerSize(gridW,gridH) + changeSheetContainerSize(gridW, gridH) if(isRefreshCanvas){ luckysheetrefreshgrid($("#luckysheet-cell-main").scrollLeft(), $("#luckysheet-cell-main").scrollTop()); @@ -152,11 +152,11 @@ export function changeSheetContainerSize(gridW, gridH){ $("#luckysheet-cell-main").height(Store.cellmainHeight); $("#luckysheet-rows-h").height(Store.cellmainHeight - Store.cellMainSrollBarSize); - $("#luckysheet-scrollbar-y").height(Store.cellmainHeight + Store.columeHeaderHeight-Store.cellMainSrollBarSize-3); + $("#luckysheet-scrollbar-y").height(Store.cellmainHeight + Store.columeHeaderHeight - Store.cellMainSrollBarSize - 3); $("#luckysheet-scrollbar-x").height(Store.cellMainSrollBarSize); $("#luckysheet-scrollbar-y").width(Store.cellMainSrollBarSize); - $("#luckysheet-scrollbar-x").width(Store.cellmainWidth).css("left",Store.rowHeaderWidth-1); + $("#luckysheet-scrollbar-x").width(Store.cellmainWidth).css("left", Store.rowHeaderWidth - 1); Store.luckysheetTableContentHW = [ Store.cellmainWidth + Store.rowHeaderWidth - Store.cellMainSrollBarSize, diff --git a/src/controllers/sheetmanage.js b/src/controllers/sheetmanage.js index 2b6596e..da760a5 100644 --- a/src/controllers/sheetmanage.js +++ b/src/controllers/sheetmanage.js @@ -6,6 +6,7 @@ import luckysheetcreatedom from '../global/createdom'; import tooltip from '../global/tooltip'; import formula from '../global/formula'; import { luckysheetrefreshgrid, jfrefreshgrid_rhcw } from '../global/refresh'; +import rhchInit from '../global/rhchInit'; import editor from '../global/editor'; import { luckysheetextendtable, luckysheetdeletetable } from '../global/extend'; import { isRealNum } from '../global/validate'; @@ -840,26 +841,8 @@ const sheetmanage = { } createFilterOptions(file["filter_select"], file["filter"]); - - Store.scrollRefreshSwitch = false; - if(file["scrollLeft"] != null && file["scrollLeft"] > 0){ - $("#luckysheet-scrollbar-x").scrollLeft(file["scrollLeft"]); - } - else{ - $("#luckysheet-scrollbar-x").scrollLeft(0); - } - - if(file["scrollTop"] != null && file["scrollTop"] > 0){ - $("#luckysheet-scrollbar-y").scrollTop(file["scrollTop"]); - } - else{ - $("#luckysheet-scrollbar-y").scrollTop(0); - } - setTimeout(() => { - Store.scrollRefreshSwitch = true; - }, 0); - jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length, false); + rhchInit(Store.flowdata.length, Store.flowdata[0].length); }, restoreselect: function() { let index = this.getSheetIndex(Store.currentSheetIndex); @@ -1073,7 +1056,33 @@ const sheetmanage = { $("#luckysheet-cols-h-cells_0").css("width", Store.ch_width); //width更新 $("#luckysheet-scrollbar-x div").width(Store.ch_width); - $("#luckysheet-scrollbar-y div").height(Store.rh_height + Store.columeHeaderHeight-Store.cellMainSrollBarSize-3 ); + $("#luckysheet-scrollbar-y div").height(Store.rh_height + Store.columeHeaderHeight - Store.cellMainSrollBarSize - 3); + + //等待滚动条dom宽高计算完成后 初始化该表格滚动位置 + let index = this.getSheetIndex(Store.currentSheetIndex); + let file = Store.luckysheetfile[index]; + + + Store.scrollRefreshSwitch = false; + + if(file["scrollLeft"] != null && file["scrollLeft"] > 0){ + $("#luckysheet-scrollbar-x").scrollLeft(file["scrollLeft"] * Store.zoomRatio); + } + else{ + $("#luckysheet-scrollbar-x").scrollLeft(0); + } + + if(file["scrollTop"] != null && file["scrollTop"] > 0){ + $("#luckysheet-scrollbar-y").scrollTop(file["scrollTop"] * Store.zoomRatio); + } + else{ + $("#luckysheet-scrollbar-y").scrollTop(0); + } + + setTimeout(() => { + Store.scrollRefreshSwitch = true; + }, 0); + zoomNumberDomBind(Store.zoomRatio); }, setCurSheet: function(index) { diff --git a/src/demoData/sheetCell.js b/src/demoData/sheetCell.js index f1b4f2c..e16bdc9 100644 --- a/src/demoData/sheetCell.js +++ b/src/demoData/sheetCell.js @@ -5581,7 +5581,7 @@ const sheetCell = { "column_focus": 0 }], "luckysheet_selection_range": [], - "scrollLeft": 0, - "scrollTop": 0 + "scrollLeft": 300, + "scrollTop": 500 } export default sheetCell \ No newline at end of file