Browse Source

feat(zoom redo undo suport): redo undo

master
liuyang 5 years ago
parent
commit
4d0390675f
  1. 13
      src/controllers/controlHistory.js
  2. 37
      src/controllers/zoom.js

13
src/controllers/controlHistory.js

@ -3,6 +3,7 @@ import server from './server';
import pivotTable from './pivotTable';
import conditionformat from './conditionformat';
import luckysheetPostil from './postil';
import {zoomRefreshView,zoomNumberDomBind} from './zoom';
import { createFilter, createFilterOptions, labelFilterOptionState } from './filter';
import formula from '../global/formula';
import json from '../global/json';
@ -322,6 +323,12 @@ const controlHistory = {
}
}
}
else if (ctr.type=="zoomChange"){
Store.zoomRatio = ctr.zoomRatio;
server.saveParam("all", ctr.currentSheetIndex, ctr.zoomRatio, { "k": "zoomRatio" });
zoomNumberDomBind();
zoomRefreshView();
}
cleargridelement(e);
Store.clearjfundo = true;
@ -542,6 +549,12 @@ const controlHistory = {
}
}
}
else if (ctr.type=="zoomChange"){
Store.zoomRatio = ctr.curZoomRatio;
server.saveParam("all", ctr.currentSheetIndex, ctr.curZoomRatio, { "k": "zoomRatio" });
zoomNumberDomBind();
zoomRefreshView();
}
Store.clearjfundo = true;
}

37
src/controllers/zoom.js

@ -3,6 +3,7 @@ import locale from '../locale/locale';
import { replaceHtml } from '../utils/util';
import {changeSheetContainerSize} from './resize';
import { jfrefreshgrid_rhcw } from '../global/refresh';
import server from './server';
@ -13,11 +14,27 @@ export function zoomChange(ratio){
return;
}
Store.zoomRatio = ratio;
clearTimeout(luckysheetZoomTimeout);
luckysheetZoomTimeout = setTimeout(() => {
if (Store.clearjfundo) {
Store.jfredo.push({
"type": "zoomChange",
"zoomRatio": Store.zoomRatio,
"curZoomRatio": ratio,
"sheetIndex": Store.currentSheetIndex,
});
}
Store.zoomRatio = ratio;
server.saveParam("all", Store.currentSheetIndex, Store.zoomRatio, { "k": "zoomRatio" });
zoomRefreshView();
}, 100);
}
export function zoomRefreshView(){
let $scrollLeft = $("#luckysheet-scrollbar-x"), $scrollTop = $("#luckysheet-scrollbar-y");
let sl = $scrollLeft.scrollLeft(), st = $scrollTop.scrollTop();
@ -30,10 +47,6 @@ export function zoomChange(ratio){
$scrollLeft.scrollLeft(sl+wc-wp);
$scrollTop.scrollTop(st+hc-hp);
}, 100);
}
@ -58,7 +71,7 @@ export function zoomInitial(){
currentRatio = 0.1;
}
Store.zoomRatio = currentRatio;
// Store.zoomRatio = currentRatio;
zoomChange(currentRatio);
zoomNumberDomBind(currentRatio);
});
@ -82,16 +95,16 @@ export function zoomInitial(){
currentRatio = 4;
}
Store.zoomRatio = currentRatio;
// Store.zoomRatio = currentRatio;
zoomChange(currentRatio);
zoomNumberDomBind(currentRatio);
});
$("#luckysheet-zoom-slider").click(function(e){
$("#luckysheet-zoom-slider").mousedown(function(e){
let xoffset = $(this).offset().left, pageX = e.pageX;
let currentRatio = positionToRatio(pageX-xoffset);
Store.zoomRatio = currentRatio;
// Store.zoomRatio = currentRatio;
zoomChange(currentRatio);
zoomNumberDomBind(currentRatio);
});
@ -118,7 +131,7 @@ export function zoomInitial(){
pos = 0;
}
Store.zoomRatio = currentRatio;
// Store.zoomRatio = currentRatio;
zoomChange(currentRatio);
let r = Math.round(currentRatio*100) + "%";
$("#luckysheet-zoom-ratioText").html(r);
@ -136,7 +149,7 @@ export function zoomInitial(){
});
$("#luckysheet-zoom-ratioText").click(function(){
Store.zoomRatio = 1;
// Store.zoomRatio = 1;
zoomChange(1);
zoomNumberDomBind(1);
});

Loading…
Cancel
Save