mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
Do not recalculate additionalWidth on every line of multiline text
This is just a minor improvement (optimization) to _setTextData(): Flag shouldAddEllipsis is not changed inside the loop, thus no need to recalculate the value of additionalWidth for every line of the original text.
This commit is contained in:
parent
adcd6b9c96
commit
6c53a2b27a
@ -356,11 +356,11 @@ export class Text extends Shape {
|
|||||||
|
|
||||||
this.textArr = [];
|
this.textArr = [];
|
||||||
getDummyContext().font = this._getContextFont();
|
getDummyContext().font = this._getContextFont();
|
||||||
|
var additionalWidth = shouldAddEllipsis
|
||||||
|
? this._getTextWidth(ELLIPSIS)
|
||||||
|
: 0;
|
||||||
for (var i = 0, max = lines.length; i < max; ++i) {
|
for (var i = 0, max = lines.length; i < max; ++i) {
|
||||||
var line = lines[i];
|
var line = lines[i];
|
||||||
var additionalWidth = shouldAddEllipsis
|
|
||||||
? this._getTextWidth(ELLIPSIS)
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
var lineWidth = this._getTextWidth(line);
|
var lineWidth = this._getTextWidth(line);
|
||||||
if (fixedWidth && lineWidth > maxWidth) {
|
if (fixedWidth && lineWidth > maxWidth) {
|
||||||
|
Loading…
Reference in New Issue
Block a user