Browse Source

fix(big data slowly): speed up

master
wbfsa 5 years ago
parent
commit
5109873500
  1. 60
      src/controllers/handler.js
  2. 2
      src/controllers/sheetmanage.js
  3. 12
      src/controllers/zoom.js
  4. 48
      src/global/createdom.js
  5. 10
      src/global/draw.js
  6. 3
      src/global/formula.js
  7. 2
      src/global/getRowlen.js

60
src/controllers/handler.js

@ -100,6 +100,36 @@ export default function luckysheetHandler() {
} }
}()); }());
$("#luckysheet-sheet-container-c").mousewheel(function (event, delta) {
let scrollNum = event.deltaFactor<40?1:(event.deltaFactor<80?2:3);
let scrollLeft = $(this).scrollLeft();
if(event.deltaY != 0){
if(event.deltaY <0){
scrollLeft = scrollLeft + 10*scrollNum;
}
else{
scrollLeft = scrollLeft - 10*scrollNum;
}
}
else if(event.deltaX != 0){
if(event.deltaX >0){
scrollLeft = scrollLeft + 10*scrollNum;
}
else{
scrollLeft = scrollLeft - 10*scrollNum;
}
}
$(this).scrollLeft(scrollLeft);
event.preventDefault();
});
//滚动监听 //滚动监听
$("#luckysheet-cell-main").scroll(function () { $("#luckysheet-cell-main").scroll(function () {
@ -128,20 +158,24 @@ export default function luckysheetHandler() {
clearTimeout(mousewheelArrayUniqueTimeout); clearTimeout(mousewheelArrayUniqueTimeout);
if(Store.visibledatacolumn_unique!=null){ if(Store.visibledatacolumn.length!=visibledatacolumn_c.length){
visibledatacolumn_c = Store.visibledatacolumn_unique; if(Store.visibledatacolumn_unique!=null){
} visibledatacolumn_c = Store.visibledatacolumn_unique;
else{ }
visibledatacolumn_c = ArrayUnique(visibledatacolumn_c); else{
Store.visibledatacolumn_unique = visibledatacolumn_c; visibledatacolumn_c = ArrayUnique(visibledatacolumn_c);
Store.visibledatacolumn_unique = visibledatacolumn_c;
}
} }
if(Store.visibledatarow_unique!=null){ if(Store.visibledatarow.length!=visibledatarow_c.length){
visibledatarow_c = Store.visibledatarow_unique; if(Store.visibledatarow_unique!=null){
} visibledatarow_c = Store.visibledatarow_unique;
else{ }
visibledatarow_c = ArrayUnique(visibledatarow_c); else{
Store.visibledatarow_unique = visibledatarow_c; visibledatarow_c = ArrayUnique(visibledatarow_c);
Store.visibledatarow_unique = visibledatarow_c;
}
} }
// visibledatacolumn_c = ArrayUnique(visibledatacolumn_c); // visibledatacolumn_c = ArrayUnique(visibledatacolumn_c);
@ -204,7 +238,7 @@ export default function luckysheetHandler() {
mousewheelArrayUniqueTimeout = setTimeout(() => { mousewheelArrayUniqueTimeout = setTimeout(() => {
Store.visibledatacolumn_unique = null; Store.visibledatacolumn_unique = null;
Store.visibledatarow_unique = null; Store.visibledatarow_unique = null;
}, 200); }, 500);
}); });
$("#luckysheet-scrollbar-x").scroll(function(){ $("#luckysheet-scrollbar-x").scroll(function(){

2
src/controllers/sheetmanage.js

@ -688,6 +688,8 @@ const sheetmanage = {
colwidth = c2 + 1; colwidth = c2 + 1;
} }
Store.flowdata = data;
luckysheetcreatedom(colwidth, rowheight, data, menu, title); luckysheetcreatedom(colwidth, rowheight, data, menu, title);
setTimeout(function () { setTimeout(function () {

12
src/controllers/zoom.js

@ -35,18 +35,18 @@ export function zoomChange(ratio){
} }
export function zoomRefreshView(){ export function zoomRefreshView(){
let $scrollLeft = $("#luckysheet-scrollbar-x"), $scrollTop = $("#luckysheet-scrollbar-y"); // let $scrollLeft = $("#luckysheet-scrollbar-x"), $scrollTop = $("#luckysheet-scrollbar-y");
let sl = $scrollLeft.scrollLeft(), st = $scrollTop.scrollTop(); // let sl = $scrollLeft.scrollLeft(), st = $scrollTop.scrollTop();
let wp = $scrollLeft.find("div").width(), hp = $scrollTop.find("div").height(); // let wp = $scrollLeft.find("div").width(), hp = $scrollTop.find("div").height();
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length); jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
changeSheetContainerSize(); changeSheetContainerSize();
let wc = $scrollLeft.find("div").width(), hc = $scrollTop.find("div").height(); // let wc = $scrollLeft.find("div").width(), hc = $scrollTop.find("div").height();
$scrollLeft.scrollLeft(sl+wc-wp); // $scrollLeft.scrollLeft(sl+wc-wp);
$scrollTop.scrollTop(st+hc-hp); // $scrollTop.scrollTop(st+hc-hp);
} }

48
src/global/createdom.js

@ -22,35 +22,35 @@ import locale from '../locale/locale';
import {menuToolBarWidth} from '../controllers/resize' import {menuToolBarWidth} from '../controllers/resize'
export default function luckysheetcreatedom(colwidth, rowheight, data, menu, title) { export default function luckysheetcreatedom(colwidth, rowheight, data, menu, title) {
//最少30行 // //最少30行
if(rowheight < 30){ // if(rowheight < 30){
rowheight = 30; // rowheight = 30;
} // }
//最少22列 // //最少22列
if(colwidth < 22){ // if(colwidth < 22){
colwidth = 22; // colwidth = 22;
} // }
let gh = gridHTML(); let gh = gridHTML();
gh = replaceHtml(gh, { "logotitle": title });//设置title gh = replaceHtml(gh, { "logotitle": title });//设置title
gh = replaceHtml(gh, { "menu": menuToolBar() });//设置需要显示的菜单 gh = replaceHtml(gh, { "menu": menuToolBar() });//设置需要显示的菜单
if (data.length == 0) { // if (data.length == 0) {
Store.flowdata = datagridgrowth(data, rowheight, colwidth); // Store.flowdata = datagridgrowth(data, rowheight, colwidth);
} // }
else if (data.length < rowheight && data[0].length < colwidth) { // else if (data.length < rowheight && data[0].length < colwidth) {
Store.flowdata = datagridgrowth(data, rowheight - data.length, colwidth - data[0].length); // Store.flowdata = datagridgrowth(data, rowheight - data.length, colwidth - data[0].length);
} // }
else if (data.length < rowheight) { // else if (data.length < rowheight) {
Store.flowdata = datagridgrowth(data, rowheight - data.length, 0); // Store.flowdata = datagridgrowth(data, rowheight - data.length, 0);
} // }
else if (data[0].length < colwidth) { // else if (data[0].length < colwidth) {
Store.flowdata = datagridgrowth(data, 0, colwidth - data[0].length); // Store.flowdata = datagridgrowth(data, 0, colwidth - data[0].length);
} // }
else { // else {
Store.flowdata = data; // Store.flowdata = data;
} // }
let flowHTML = flow; let flowHTML = flow;
if(Store.config == null){ if(Store.config == null){
@ -103,7 +103,7 @@ export default function luckysheetcreatedom(colwidth, rowheight, data, menu, tit
menuToolBarWidth(); menuToolBarWidth();
$("#luckysheet-scrollbar-x div").width(Store.ch_width); $("#luckysheet-scrollbar-x div").width(Store.ch_width);
$("#luckysheet-scrollbar-y div").height(Store.rh_height - 30); $("#luckysheet-scrollbar-y div").height(Store.rh_height + Store.columeHeaderHeight - Store.cellMainSrollBarSize - 3);
//新建行菜单 //新建行菜单
$("body").append(maskHTML); $("body").append(maskHTML);

10
src/global/draw.js

@ -1222,10 +1222,10 @@ let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckyshee
]; ];
luckysheetTableContent.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]); luckysheetTableContent.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]);
//数据验证(单元格左上角红色小三角标示)
let dataVerification = dataVerificationCtrl.dataVerification; let dataVerification = dataVerificationCtrl.dataVerification;
let cellValue = getcellvalue(r, c, null);
if(dataVerification != null && dataVerification[r + '_' + c] != null && !dataVerificationCtrl.validateCellData(cellValue, dataVerification[r + '_' + c])){ if(dataVerification != null && dataVerification[r + '_' + c] != null && !dataVerificationCtrl.validateCellData(value, dataVerification[r + '_' + c])){
//单元格左上角红色小三角标示
let dv_w = 5 * Store.zoomRatio, dv_h = 5 * Store.zoomRatio; //红色小三角宽高 let dv_w = 5 * Store.zoomRatio, dv_h = 5 * Store.zoomRatio; //红色小三角宽高
luckysheetTableContent.beginPath(); luckysheetTableContent.beginPath();
@ -2169,7 +2169,7 @@ function cellTextRender(textInfo, ctx, option){
Math.floor((pos_x +c.endX)/Store.zoomRatio)+0.5 , Math.floor((pos_x +c.endX)/Store.zoomRatio)+0.5 ,
Math.floor((pos_y+c.endY)/Store.zoomRatio)+0.5 , Math.floor((pos_y+c.endY)/Store.zoomRatio)+0.5 ,
); );
ctx.lineWidth = Math.floor(c.fs/9); ctx.lineWidth = 1;
ctx.strokeStyle = ctx.fillStyle; ctx.strokeStyle = ctx.fillStyle;
ctx.stroke(); ctx.stroke();
ctx.closePath(); ctx.closePath();
@ -2188,7 +2188,7 @@ function cellTextRender(textInfo, ctx, option){
Math.floor((pos_x +item.endX)/Store.zoomRatio)+0.5, Math.floor((pos_x +item.endX)/Store.zoomRatio)+0.5,
Math.floor((pos_y+ item.endY)/Store.zoomRatio)+0.5 Math.floor((pos_y+ item.endY)/Store.zoomRatio)+0.5
); );
ctx.lineWidth = Math.floor(item.fs/9); ctx.lineWidth = 1;
ctx.strokeStyle = ctx.fillStyle; ctx.strokeStyle = ctx.fillStyle;
ctx.stroke(); ctx.stroke();
ctx.closePath(); ctx.closePath();

3
src/global/formula.js

@ -4862,6 +4862,7 @@ const luckysheetformula = {
} }
editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据 editor.webWorkerFlowDataCache(Store.flowdata);//worker存数据
_this.groupValuesRefreshData = [];
} }
}, },
delFunctionGroup: function(r, c, index) { delFunctionGroup: function(r, c, index) {
@ -4996,7 +4997,7 @@ const luckysheetformula = {
let _locale = locale(); let _locale = locale();
let locale_formulaMore = _locale.formulaMore; let locale_formulaMore = _locale.formulaMore;
console.log(txt,r,c) // console.log(txt,r,c)
if(txt.indexOf(_this.error.r) > -1){ if(txt.indexOf(_this.error.r) > -1){
return [false, _this.error.r, txt]; return [false, _this.error.r, txt];
} }

2
src/global/getRowlen.js

@ -1104,7 +1104,7 @@ function getCellTextInfo(cell , ctx, option){
wordGroup.left = left; wordGroup.left = left;
wordGroup.top = top; wordGroup.top = top;
console.log(left, top, cumWordHeight, size.height); // console.log(left, top, cumWordHeight, size.height);
drawLineInfo(wordGroup, cancelLine, underLine,{ drawLineInfo(wordGroup, cancelLine, underLine,{
width:wordGroup.width, width:wordGroup.width,

Loading…
Cancel
Save