Browse Source

feat(zoom redo undo suport): redo undo

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

13
src/controllers/controlHistory.js

@ -3,6 +3,7 @@ import server from './server';
import pivotTable from './pivotTable'; import pivotTable from './pivotTable';
import conditionformat from './conditionformat'; import conditionformat from './conditionformat';
import luckysheetPostil from './postil'; import luckysheetPostil from './postil';
import {zoomRefreshView,zoomNumberDomBind} from './zoom';
import { createFilter, createFilterOptions, labelFilterOptionState } from './filter'; import { createFilter, createFilterOptions, labelFilterOptionState } from './filter';
import formula from '../global/formula'; import formula from '../global/formula';
import json from '../global/json'; 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); cleargridelement(e);
Store.clearjfundo = true; 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; Store.clearjfundo = true;
} }

51
src/controllers/zoom.js

@ -3,6 +3,7 @@ import locale from '../locale/locale';
import { replaceHtml } from '../utils/util'; import { replaceHtml } from '../utils/util';
import {changeSheetContainerSize} from './resize'; import {changeSheetContainerSize} from './resize';
import { jfrefreshgrid_rhcw } from '../global/refresh'; import { jfrefreshgrid_rhcw } from '../global/refresh';
import server from './server';
@ -13,27 +14,39 @@ export function zoomChange(ratio){
return; return;
} }
Store.zoomRatio = ratio;
clearTimeout(luckysheetZoomTimeout); clearTimeout(luckysheetZoomTimeout);
luckysheetZoomTimeout = setTimeout(() => { 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" });
let $scrollLeft = $("#luckysheet-scrollbar-x"), $scrollTop = $("#luckysheet-scrollbar-y"); zoomRefreshView();
let sl = $scrollLeft.scrollLeft(), st = $scrollTop.scrollTop(); }, 100);
}
let wp = $scrollLeft.find("div").width(), hp = $scrollTop.find("div").height(); export function zoomRefreshView(){
let $scrollLeft = $("#luckysheet-scrollbar-x"), $scrollTop = $("#luckysheet-scrollbar-y");
let sl = $scrollLeft.scrollLeft(), st = $scrollTop.scrollTop();
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); let wp = $scrollLeft.find("div").width(), hp = $scrollTop.find("div").height();
changeSheetContainerSize();
let wc = $scrollLeft.find("div").width(), hc = $scrollTop.find("div").height(); jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
changeSheetContainerSize();
$scrollLeft.scrollLeft(sl+wc-wp); let wc = $scrollLeft.find("div").width(), hc = $scrollTop.find("div").height();
$scrollTop.scrollTop(st+hc-hp);
}, 100); $scrollLeft.scrollLeft(sl+wc-wp);
$scrollTop.scrollTop(st+hc-hp);
} }
@ -58,7 +71,7 @@ export function zoomInitial(){
currentRatio = 0.1; currentRatio = 0.1;
} }
Store.zoomRatio = currentRatio; // Store.zoomRatio = currentRatio;
zoomChange(currentRatio); zoomChange(currentRatio);
zoomNumberDomBind(currentRatio); zoomNumberDomBind(currentRatio);
}); });
@ -82,16 +95,16 @@ export function zoomInitial(){
currentRatio = 4; currentRatio = 4;
} }
Store.zoomRatio = currentRatio; // Store.zoomRatio = currentRatio;
zoomChange(currentRatio); zoomChange(currentRatio);
zoomNumberDomBind(currentRatio); zoomNumberDomBind(currentRatio);
}); });
$("#luckysheet-zoom-slider").click(function(e){ $("#luckysheet-zoom-slider").mousedown(function(e){
let xoffset = $(this).offset().left, pageX = e.pageX; let xoffset = $(this).offset().left, pageX = e.pageX;
let currentRatio = positionToRatio(pageX-xoffset); let currentRatio = positionToRatio(pageX-xoffset);
Store.zoomRatio = currentRatio; // Store.zoomRatio = currentRatio;
zoomChange(currentRatio); zoomChange(currentRatio);
zoomNumberDomBind(currentRatio); zoomNumberDomBind(currentRatio);
}); });
@ -118,7 +131,7 @@ export function zoomInitial(){
pos = 0; pos = 0;
} }
Store.zoomRatio = currentRatio; // Store.zoomRatio = currentRatio;
zoomChange(currentRatio); zoomChange(currentRatio);
let r = Math.round(currentRatio*100) + "%"; let r = Math.round(currentRatio*100) + "%";
$("#luckysheet-zoom-ratioText").html(r); $("#luckysheet-zoom-ratioText").html(r);
@ -136,7 +149,7 @@ export function zoomInitial(){
}); });
$("#luckysheet-zoom-ratioText").click(function(){ $("#luckysheet-zoom-ratioText").click(function(){
Store.zoomRatio = 1; // Store.zoomRatio = 1;
zoomChange(1); zoomChange(1);
zoomNumberDomBind(1); zoomNumberDomBind(1);
}); });

Loading…
Cancel
Save