Skip to content
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

Merged
merged 1 commit into from
Feb 25, 2017

Conversation

asturur
Copy link
Member

@asturur asturur commented Feb 25, 2017

No description provided.

leftOffset = (lineIndex === 0 && charIndex === 0)
? this._getLineLeftOffset(this._getLineWidth(this.ctx, lineIndex))
: boundaries.leftOffset,
leftOffset = boundaries.leftOffset,
Copy link
Member Author

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] = {};
}

Copy link
Member Author

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);
Copy link
Member Author

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);
Copy link
Member Author

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

@asturur asturur merged commit 14e8826 into master Feb 25, 2017
@asturur asturur deleted the itextfixes branch February 25, 2017 04:01
asturur added a commit that referenced this pull request Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant