Skip to content

Commit

Permalink
refact: add RichText as container.
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Feb 5, 2020
1 parent 87b7777 commit 8e8ac10
Show file tree
Hide file tree
Showing 13 changed files with 1,137 additions and 68 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
@@ -1,2 +1,4 @@
/dist
/node_modules
/node_modules
/esm
/lib
2 changes: 1 addition & 1 deletion src/canvas/Painter.ts
Expand Up @@ -437,7 +437,7 @@ export default class CanvasPainter implements PainterBase {
for (i = start; i < layer.__endIndex; i++) {
const el = list[i];
this._doPaintEl(el, layer, paintAll, scope);
el.__dirty = el.__dirtyText = false;
el.__dirty = false;

if (useTimer) {
// Date.now can be executed in 13,025,305 ops/second.
Expand Down
8 changes: 4 additions & 4 deletions src/contain/text.ts
Expand Up @@ -83,7 +83,7 @@ export function getBoundingRect(
}

export function adjustTextX(x: number, width: number, textAlign: CanvasTextAlign): number {
// FIXME Right to left language
// TODO Right to left language
if (textAlign === 'right') {
x -= width;
}
Expand All @@ -93,11 +93,11 @@ export function adjustTextX(x: number, width: number, textAlign: CanvasTextAlign
return x;
}

export function adjustTextY(y: number, height: number, textVerticalAlign: CanvasTextBaseline): number {
if (textVerticalAlign === 'middle') {
export function adjustTextY(y: number, height: number, textBaseline: CanvasTextBaseline): number {
if (textBaseline === 'middle') {
y -= height / 2;
}
else if (textVerticalAlign === 'bottom') {
else if (textBaseline === 'bottom') {
y -= height;
}
return y;
Expand Down
2 changes: 0 additions & 2 deletions src/container/Group.ts
Expand Up @@ -75,9 +75,7 @@ export default class Group extends Element {
*/
add(child: Element): Group {
if (child && child !== this && child.parent !== this) {

this._children.push(child);

this._doAdd(child);
}

Expand Down

0 comments on commit 8e8ac10

Please sign in to comment.