Skip to content

Commit

Permalink
rewrite border structure
Browse files Browse the repository at this point in the history
  • Loading branch information
myliang committed Feb 13, 2019
1 parent 02c8217 commit cde2244
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 226 deletions.
7 changes: 1 addition & 6 deletions index.html
Expand Up @@ -12,13 +12,8 @@
x.spreadsheet('#x-spreadsheet-demo')
.loadData({
freeze: [2, 2],
borders: [
[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' },
{ bgcolor: '#f4f5f8', wrapText: true, color: '#900b09', bb: ['thin', '#0366d6'], bt: ['thin', '#0366d6'], br: ['thin', '#0366d6'], bl: ['thin', '#0366d6'] },
],
merges: [
[[2, 2], [3, 3]],
Expand Down
26 changes: 9 additions & 17 deletions src/component/table.js
Expand Up @@ -57,35 +57,25 @@ function renderCell(rindex, cindex) {
}
}

/*
function renderCellBorder(cell, ri, ci) {
const { draw, data } = this;
if (cell && cell.si !== undefined) {
// console.log('cell:', cell, ri, ci);
const style = data.getStyle(cell.si);
if (style) {
const {
bti, bri, bbi, bli,
bt, br, bb, bl,
} = style;
// console.log('bti:', bti);
if (bti !== undefined || bri !== undefined
|| bbi !== undefined || bli !== undefined) {
// console.log('::::::::::', ri, ci);
if (bt !== undefined || br !== undefined
|| bb !== undefined || bl !== undefined) {
const dbox = getDrawBox.call(this, ri, ci);
// console.log('ri:', ri, ',ci:', ci, 'style:', style, dbox);
dbox.setBorders(
data.getBorder(bti),
data.getBorder(bri),
data.getBorder(bbi),
data.getBorder(bli),
);
dbox.setBorders(bt, br, bb, bl);
draw.strokeBorders(dbox);
}
}
}
}
*/

/*
function renderCellBorder(ri, ci, bs) {
const {
bt, br, bb, bl,
Expand All @@ -98,6 +88,7 @@ function renderCellBorder(ri, ci, bs) {
draw.strokeBorders(dbox);
}
}
*/

function renderContent(rowStart, rowLen, colStart, colLen, scrollOffset) {
const { draw, data } = this;
Expand All @@ -109,8 +100,9 @@ function renderContent(rowStart, rowLen, colStart, colLen, scrollOffset) {
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(viewRangeIndexes, (cell, ri, ci) => {
// renderCellBorder.call(this, ri, ci, bt, br, bb, bl);
renderCellBorder.call(this, cell, ri, ci);
});

/*
Expand Down

1 comment on commit cde2244

@myliang
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed #34

Please sign in to comment.