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

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tubiaoge committed Aug 18, 2020
2 parents 52375dc + 17ddd13 commit fa1b189
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions src/controllers/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ 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;
}

Store.zoomRatio = ratio;

jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);

changeSheetContainerSize();
clearTimeout(luckysheetZoomTimeout);
luckysheetZoomTimeout = setTimeout(() => {
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
changeSheetContainerSize();
}, 100);


}


Expand All @@ -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;
}
Expand All @@ -51,6 +62,10 @@ export function zoomInitial(){

currentRatio = currentRatio+0.1;

if(currentRatio==Store.zoomRatio){
currentRatio = currentRatio+0.1;
}

if(currentRatio>=4){
currentRatio = 4;
}
Expand All @@ -71,6 +86,7 @@ export function zoomInitial(){

$("#luckysheet-zoom-cursor").mousedown(function(e){
let curentX = e.pageX,cursorLeft = parseFloat($("#luckysheet-zoom-cursor").css("left"));
$("#luckysheet-zoom-cursor").css("transition","none");
$(document).off("mousemove.zoomCursor").on("mousemove.zoomCursor",function(event){
let moveX = event.pageX;
let offsetX = moveX - curentX;
Expand Down Expand Up @@ -99,6 +115,7 @@ export function zoomInitial(){

$(document).off("mouseup.zoomCursor").on("mouseup.zoomCursor",function(event){
$(document).off(".zoomCursor");
$("#luckysheet-zoom-cursor").css("transition","all 0.3s");
});

e.stopPropagation();
Expand Down
2 changes: 1 addition & 1 deletion src/global/getRowlen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit fa1b189

Please sign in to comment.