-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove some code from ITEXT, do not pollute styles if not necessary #3743
Conversation
leftOffset = (lineIndex === 0 && charIndex === 0) | ||
? this._getLineLeftOffset(this._getLineWidth(this.ctx, lineIndex)) | ||
: boundaries.leftOffset, | ||
leftOffset = boundaries.leftOffset, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boundaries.leftOffset and this._getLineLeftOffset(this._getLineWidth(this.ctx, lineIndex)) carry the same value. no need to make a special case.
if (!this.styles[lineIndex + 1]) { | ||
this.styles[lineIndex + 1] = {}; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to create an empty style object for a line just because maybe we will put something into it.
// remove lines from the previous line since they're on a new line now | ||
delete this.styles[lineIndex][index]; | ||
} | ||
} | ||
this.styles[lineIndex + 1] = newLineStyles; | ||
somethingAdded && (this.styles[lineIndex + 1] = newLineStyles); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create the new line style only if necessary
} | ||
} | ||
//TODO: evaluate if delete old style lines with offset -1 | ||
fabric.IText.prototype.shiftLineStyles.call(this, lineIndex, offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the prototype function does exactly the same thing
No description provided.