Fix ellipsis rendering for Konva.Text

This commit is contained in:
Anton Lavrenov
2020-12-18 11:12:19 -05:00
parent e6c842c83f
commit 6fcfd4de54
5 changed files with 12 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
* Fix wrong size calculations for `Konva.Line` with tension
* Fix `shape.intersects()` behavior when a node is dragged
* Fix ellipsis rendering for `Konva.Text`
## 7.2.1

View File

@@ -8,7 +8,7 @@
* Konva JavaScript Framework v7.2.1
* http://konvajs.org/
* Licensed under the MIT
* Date: Wed Dec 16 2020
* Date: Fri Dec 18 2020
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@@ -13831,7 +13831,7 @@
var mid = (low + high) >>> 1, substr = line.slice(0, mid + 1), substrWidth = this._getTextWidth(substr) + additionalWidth;
if (substrWidth <= maxWidth) {
low = mid + 1;
match = substr + (shouldAddEllipsis ? ELLIPSIS : '');
match = substr;
matchWidth = substrWidth;
}
else {

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -463,7 +463,7 @@ export class Text extends Shape<TextConfig> {
substrWidth = this._getTextWidth(substr) + additionalWidth;
if (substrWidth <= maxWidth) {
low = mid + 1;
match = substr + (shouldAddEllipsis ? ELLIPSIS : '');
match = substr;
matchWidth = substrWidth;
} else {
high = mid;

View File

@@ -479,6 +479,12 @@ suite('Text', function () {
assert.equal(text.textArr.length, 7);
assert.equal(text.textArr[6].text.slice(-1), '…');
var trace =
"clearRect(0,0,578,200);save();transform(1,0,0,1,10,10);font=normal normal 14px Calibri;textBaseline=middle;textAlign=left;translate(0,0);save();fillStyle=black;fillText(HEADING,18.117,7);restore();save();fillStyle=black;fillText(,50,21);restore();save();fillStyle=black;fillText(All the world's,8.687,35);restore();save();fillStyle=black;fillText(a stage, merely,7.826,49);restore();save();fillStyle=black;fillText(players. They,11.903,63);restore();save();fillStyle=black;fillText(have theirrrrrrr,8.222,77);restore();save();fillStyle=black;fillText(exits and…,17.922,91);restore();restore();";
console.log(layer.getContext().getTrace());
assert.equal(layer.getContext().getTrace(), trace);
});
// ======================================================