Browse Source

fix(text get wrong height when zoom): fix height

master
wbfsa 5 years ago
parent
commit
106f1fd111
  1. 19
      src/controllers/zoom.js
  2. 2
      src/global/getRowlen.js

19
src/controllers/zoom.js

@ -5,6 +5,9 @@ import {changeSheetContainerSize} from './resize';
import { jfrefreshgrid_rhcw } from '../global/refresh';
let luckysheetZoomTimeout = null;
export function zoomChange(ratio){
if(Store.flowdata==null || Store.flowdata.length==0){
return;
@ -12,9 +15,13 @@ export function zoomChange(ratio){
Store.zoomRatio = ratio;
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
clearTimeout(luckysheetZoomTimeout);
luckysheetZoomTimeout = setTimeout(() => {
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
changeSheetContainerSize();
}, 100);
changeSheetContainerSize();
}
@ -31,6 +38,10 @@ export function zoomInitial(){
currentRatio = currentRatio-0.1;
if(currentRatio==Store.zoomRatio){
currentRatio = currentRatio-0.1;
}
if(currentRatio<=0.1){
currentRatio = 0.1;
}
@ -51,6 +62,10 @@ export function zoomInitial(){
currentRatio = currentRatio+0.1;
if(currentRatio==Store.zoomRatio){
currentRatio = currentRatio+0.1;
}
if(currentRatio>=4){
currentRatio = 4;
}

2
src/global/getRowlen.js

@ -181,7 +181,7 @@ function getMeasureText(value, ctx){
cache.width *= Store.zoomRatio;
cache.actualBoundingBoxDescent *= Store.zoomRatio;
cache.actualBoundingBoxAscent *= Store.zoomRatio;
Store.measureTextCache[value + "_" + ctx.font] = cache;
Store.measureTextCache[value + "_" + Store.zoomRatio + "_" + ctx.font] = cache;
return cache;
}

Loading…
Cancel
Save