Skip to content

Commit

Permalink
Fixed bug in lineClamp: 'auto' calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Aug 6, 2018
1 parent ec3d6cf commit 78bd02b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/cheetah-grid/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cheetah-grid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cheetah-grid",
"version": "0.6.0",
"version": "0.6.1",
"description": "Cheetah Grid is a high performance grid engine that works on canvas",
"keywords": [
"spreadsheet",
Expand Down
3 changes: 2 additions & 1 deletion packages/cheetah-grid/src/js/GridCanvasHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ function _multiInlineRect(grid, ctx, multiInlines, rect, col, row,
ctx.font = font || ctx.font;

if (lineClamp === 'auto') {
lineClamp = Math.max(Math.floor(rect.height / lineHeight), 1);
const rectHeight = rect.height - offset * 2 - 2/*offset added by Inline#draw*/;
lineClamp = Math.max(Math.floor(rectHeight / lineHeight), 1);
}

let buildedMultiInlines;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@

const em = ctx.measureText('あ').width;

const lineClamp = Math.floor(50 / em);
const lineClamp = Math.floor((50 - 6) / em);

//TEXT
ctx.fillStyle = '#000';
Expand Down

0 comments on commit 78bd02b

Please sign in to comment.