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

Commit

Permalink
fix(ssf column resize): change
Browse files Browse the repository at this point in the history
  • Loading branch information
DR-Univer committed Aug 8, 2020
1 parent 636046d commit 2a09f59
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 69 deletions.
26 changes: 19 additions & 7 deletions src/controllers/rowColumnOperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { getcellvalue } from '../global/getdata';
import tooltip from '../global/tooltip';
import editor from '../global/editor';
import locale from '../locale/locale';
import {getMeasureText} from '../global/getRowlen';
import { luckysheet_searcharray } from '../controllers/sheetSearch';
import Store from '../store';


Expand Down Expand Up @@ -1506,6 +1508,14 @@ function luckysheetcolsdbclick() {
}

let matchColumn = {};
let scrollTop = $("#luckysheet-cell-main").scrollTop(), drawHeight = Store.luckysheetTableContentHW[1];
let dataset_row_st = luckysheet_searcharray(Store.visibledatarow, scrollTop);
let dataset_row_ed = luckysheet_searcharray(Store.visibledatarow, scrollTop + drawHeight);
dataset_row_ed += dataset_row_ed - dataset_row_st;
if(dataset_row_ed>=d.length){
dataset_row_ed = d.length-1;
}

for(let s = 0; s < Store.luckysheet_select_save.length; s++){
let c1 = Store.luckysheet_select_save[s].column[0],
c2 = Store.luckysheet_select_save[s].column[1];
Expand All @@ -1516,8 +1526,8 @@ function luckysheetcolsdbclick() {
}

let currentColLen = Store.defaultcollen;

for(let r = 0; r < d.length; r++){
for(let r = dataset_row_st; r <= dataset_row_ed; r++){
let cell = d[r][colIndex];

if(cell == null || isRealNull(cell.v)){
Expand All @@ -1527,12 +1537,13 @@ function luckysheetcolsdbclick() {
let fontset = luckysheetfontformat(cell);
canvas.font = fontset;

let value = getcellvalue(r, colIndex, d).toString(); //单元格文本
let textMetrics = canvas.measureText(value).width; //文本宽度
let value = getcellvalue(r, colIndex, d, "m").toString(); //单元格文本
let textMetrics = getMeasureText(value, canvas).width; //文本宽度

if(textMetrics + 6 > currentColLen){
currentColLen = textMetrics + 6;
}

}

if(currentColLen != Store.defaultcollen){
Expand All @@ -1549,7 +1560,7 @@ function luckysheetcolsdbclick() {

let currentColLen = Store.defaultcollen;

for(let r = 0; r < d.length; r++){
for(let r = dataset_row_st; r <= dataset_row_ed; r++){
let cell = d[r][c];

if(cell == null || isRealNull(cell.v)){
Expand All @@ -1559,12 +1570,13 @@ function luckysheetcolsdbclick() {
let fontset = luckysheetfontformat(cell);
canvas.font = fontset;

let value = getcellvalue(r, c, d).toString(); //单元格文本
let textMetrics = canvas.measureText(value).width; //文本宽度
let value = getcellvalue(r, c, d, "m").toString(); //单元格文本
let textMetrics = getMeasureText(value, canvas).width; //文本宽度

if(textMetrics + 6 > currentColLen){
currentColLen = textMetrics + 6;
}

}

if(currentColLen != Store.defaultcollen){
Expand Down
4 changes: 2 additions & 2 deletions src/css/luckysheet-core.css
Original file line number Diff line number Diff line change
Expand Up @@ -1200,8 +1200,8 @@ div.luckysheet-sheets-add:hover, div.luckysheet-sheets-m:hover {
}

.luckysheet-left-top {
width: 45px;
height: 19px;
width: 44.5px;
height: 18.5px;
border: solid 0 #dfdfdf;
position: relative;
padding-top: 0;
Expand Down
Loading

0 comments on commit 2a09f59

Please sign in to comment.