Permalink
Browse files

Modify data structure(data.borders) and rendering

  • Loading branch information...
myliang committed Feb 12, 2019
1 parent 08cc078 commit 02c821715293e3df9c6d60190c91cbb6036c0da8
Showing with 235 additions and 72 deletions.
  1. +4 −2 index.html
  2. +1 −1 src/component/selector.js
  3. +25 −1 src/component/table.js
  4. +198 −68 src/data_proxy.js
  5. +7 −0 src/helper.js
@@ -13,10 +13,12 @@
.loadData({
freeze: [2, 2],
borders: [
['thin', '#0366d6'],
[2, 0, 2, 0, 'all', 'thin', '#0366d6'],
[8, 8, 8, 8, 'all', 'thin', '#0366d6'],
],
styles: [
{ bgcolor: '#f4f5f8', wrapText: true, color: '#900b09', bbi: 0, bti: 0, bri: 0, bli: 0 },
// { bgcolor: '#f4f5f8', wrapText: true, color: '#900b09', bbi: 0, bti: 0, bri: 0, bli: 0 },
{ bgcolor: '#f4f5f8', wrapText: true, color: '#900b09' },
],
merges: [
[[2, 2], [3, 3]],
@@ -275,7 +275,7 @@ export default class Selector {

setEnd(ri, ci) {
const { data } = this;
let [sIndexes, eIndexes] = data.calRangeIndexes2(ri, ci);
const [sIndexes, eIndexes] = data.calRangeIndexes2(ri, ci);
this.sIndexes = sIndexes;
this.eIndexes = eIndexes;
this.reset();
@@ -57,6 +57,7 @@ function renderCell(rindex, cindex) {
}
}

/*
function renderCellBorder(cell, ri, ci) {
const { draw, data } = this;
if (cell && cell.si !== undefined) {
@@ -83,6 +84,20 @@ function renderCellBorder(cell, ri, ci) {
}
}
}
*/

function renderCellBorder(ri, ci, bs) {
const {
bt, br, bb, bl,
} = bs;
const { draw } = this;
if (bt !== undefined || br !== undefined
|| bb !== undefined || bl !== undefined) {
const dbox = getDrawBox.call(this, ri, ci);
dbox.setBorders(bt, br, bb, bl);
draw.strokeBorders(dbox);
}
}

function renderContent(rowStart, rowLen, colStart, colLen, scrollOffset) {
const { draw, data } = this;
@@ -91,6 +106,14 @@ function renderContent(rowStart, rowLen, colStart, colLen, scrollOffset) {
draw.translate(col.indexWidth, row.height)
.translate(-scrollOffset.x, -scrollOffset.y);

const viewRangeIndexes = data.getViewRangeIndexes(rowStart, rowLen, colStart, colLen);
data.eachCellsInView(viewRangeIndexes, (cell, ri, ci) => renderCell.call(this, ri, ci));
data.eachMergesInView(viewRangeIndexes, (cell, ri, ci) => renderCell.call(this, ri, ci));
data.eachBordersInView(viewRangeIndexes, (ri, ci, bt, br, bb, bl) => {
renderCellBorder.call(this, ri, ci, bt, br, bb, bl);
});

/*
data.eachCellsInView(
rowStart,
rowLen,
@@ -107,11 +130,12 @@ function renderContent(rowStart, rowLen, colStart, colLen, scrollOffset) {
rowLen,
colStart,
colLen,
true,
false,
(cell, ri, ci) => {
renderCellBorder.call(this, cell, ri, ci);
},
);
*/
draw.restore();
}

Oops, something went wrong.

0 comments on commit 02c8217

Please sign in to comment.