mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
Merge pull request #1094 from zilongshanren/fix-richtext-edge-cases
fix RichText element wrap edge cases
This commit is contained in:
@@ -356,12 +356,12 @@ var RichText = cc.Class({
|
||||
if (this._lineOffsetX > 0 && fragmentWidth + this._lineOffsetX > this.maxWidth) {
|
||||
//concat previous line
|
||||
var checkStartIndex = 0;
|
||||
while (this._lineOffsetX < this.maxWidth) {
|
||||
while (this._lineOffsetX <= this.maxWidth) {
|
||||
var checkEndIndex = this._getFirstWordLen(labelString, checkStartIndex, labelString.length);
|
||||
var checkString = labelString.substr(checkStartIndex, checkEndIndex);
|
||||
var checkStringWidth = this._measureText(checkString, styleIndex);
|
||||
|
||||
if(this._lineOffsetX + checkStringWidth < this.maxWidth) {
|
||||
if(this._lineOffsetX + checkStringWidth <= this.maxWidth) {
|
||||
this._lineOffsetX += checkStringWidth;
|
||||
checkStartIndex += checkEndIndex;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user