diff --git a/src/controllers/controlHistory.js b/src/controllers/controlHistory.js index adde630f2..5614d028c 100644 --- a/src/controllers/controlHistory.js +++ b/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; } diff --git a/src/controllers/zoom.js b/src/controllers/zoom.js index d039f8574..6e38d0cf2 100644 --- a/src/controllers/zoom.js +++ b/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,27 +14,39 @@ 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" }); - let $scrollLeft = $("#luckysheet-scrollbar-x"), $scrollTop = $("#luckysheet-scrollbar-y"); - let sl = $scrollLeft.scrollLeft(), st = $scrollTop.scrollTop(); + zoomRefreshView(); + }, 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); - changeSheetContainerSize(); + let wp = $scrollLeft.find("div").width(), hp = $scrollTop.find("div").height(); - 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); - $scrollTop.scrollTop(st+hc-hp); + let wc = $scrollLeft.find("div").width(), hc = $scrollTop.find("div").height(); - }, 100); - - + $scrollLeft.scrollLeft(sl+wc-wp); + $scrollTop.scrollTop(st+hc-hp); } @@ -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); });