Skip to content

Commit e71762c

Browse files
committed
fix text overflow
1 parent 9446c73 commit e71762c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/vector/Text.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,13 @@ acgraph.vector.Text.prototype.applyTextOverflow_ = function(opt_line) {
12951295
// Copy ellipsis to avoid overwriting this.ellipsis_ because "..." can be ".." (cut) when resize happened.
12961296
var ellipsis = this.ellipsis_;
12971297

1298+
var preLastSegment = line.length > 1 && line[line.length - 2];
1299+
if (preLastSegment && preLastSegment.elipsisAlreadyApplying) {
1300+
index = goog.array.indexOf(this.segments_, peekSegment) + 1;
1301+
goog.array.splice(this.segments_, index, this.segments_.length - index);
1302+
return;
1303+
}
1304+
12981305
if (ellipsisBounds.width > this.textWidthLimit) {
12991306
cutPos = this.cutTextSegment_(this.ellipsis_, peekSegment.getStyle(), 0, this.textWidthLimit, ellipsisBounds, true);
13001307
ellipsis = this.ellipsis_.substring(0, cutPos);
@@ -1360,6 +1367,7 @@ acgraph.vector.Text.prototype.applyTextOverflow_ = function(opt_line) {
13601367
var lastSegmentInline = this.createSegment_(cutText, segment.getStyle(), segment_bounds, ellipsisBounds.width);
13611368
lastSegmentInline.x = segment.x;
13621369
lastSegmentInline.y = segment.y;
1370+
lastSegmentInline.elipsisAlreadyApplying = true;
13631371

13641372
if (segment_bounds.width + ellipsisBounds.width > this.textWidthLimit) {
13651373
cutPos = this.cutTextSegment_(this.ellipsis_, peekSegment.getStyle(), segment_bounds.width, this.textWidthLimit, ellipsisBounds, true);
@@ -1579,6 +1587,7 @@ acgraph.vector.Text.prototype.finalizeTextLine = function() {
15791587
segment = goog.array.peek(this.currentLine_);
15801588
var segment_bounds = this.getTextBounds(segment.text, segment.getStyle());
15811589

1590+
15821591
var cutLimit = this.textWidthLimit - (this.currentLineWidth_ - segment_bounds.width);
15831592
var cutPos = this.cutTextSegment_(segment.text, segment.getStyle(), 0, cutLimit, segment_bounds, true);
15841593
var cutText = segment.text.substring(0, cutPos);

0 commit comments

Comments
 (0)