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

Commit

Permalink
fix(scroll bug): scroll bug
Browse files Browse the repository at this point in the history
scroll bug
wpxp123456 committed Aug 18, 2020

Verified

This commit was signed with the committer’s verified signature.
primeos Michael Weiss
1 parent fa1b189 commit 3637fa4
Showing 3 changed files with 28 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/controllers/resize.js
Original file line number Diff line number Diff line change
@@ -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,
38 changes: 23 additions & 15 deletions src/controllers/sheetmanage.js
Original file line number Diff line number Diff line change
@@ -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';
@@ -842,24 +843,12 @@ const sheetmanage = {
createFilterOptions(file["filter_select"], file["filter"]);

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);

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 +1062,26 @@ 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];

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);
}

zoomNumberDomBind(Store.zoomRatio);
},
setCurSheet: function(index) {
4 changes: 2 additions & 2 deletions src/demoData/sheetCell.js
Original file line number Diff line number Diff line change
@@ -5581,7 +5581,7 @@ const sheetCell = {
"column_focus": 0
}],
"luckysheet_selection_range": [],
"scrollLeft": 0,
"scrollTop": 0
"scrollLeft": 300,
"scrollTop": 500
}
export default sheetCell

0 comments on commit 3637fa4

Please sign in to comment.