mirror of
https://github.com/konvajs/konva.git
synced 2025-10-07 16:13:47 +08:00
fix: add ellipsis for last line
This commit is contained in:
@@ -487,6 +487,39 @@ describe('Text', function () {
|
||||
}
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
it('multiline with ellipsis and lineWidth less than maxWidth', function () {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
|
||||
var text = new Konva.Text({
|
||||
x: 10,
|
||||
y: 10,
|
||||
text: "HEADING\nAll the\n world's a stage, merely players. They have theirrrrrrr exits and theirrrrr entrances; And one man in his time plays many parts.",
|
||||
fontSize: 14,
|
||||
fontFamily: 'Arial',
|
||||
fontStyle: 'normal',
|
||||
width: 100,
|
||||
padding: 0,
|
||||
align: 'center',
|
||||
height: 30,
|
||||
ellipsis: true,
|
||||
});
|
||||
|
||||
layer.add(text);
|
||||
stage.add(layer);
|
||||
|
||||
assert.equal(text.textArr.length, 2);
|
||||
assert.equal(text.textArr[1].text.slice(-1), '…');
|
||||
|
||||
if (isBrowser) {
|
||||
assert.equal(
|
||||
layer.getContext().getTrace(false, true),
|
||||
"clearRect(0,0,578,200);save();transform(1,0,0,1,10,10);font=normal normal 14px Arial;textBaseline=middle;textAlign=left;translate(0,0);save();fillStyle=black;fillText(HEADING,18,7);restore();save();fillStyle=black;fillText(All the…,23,21);restore();restore();"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
it('make sure we respect false for ellipsis', function () {
|
||||
var stage = addStage();
|
||||
|
Reference in New Issue
Block a user