fix calculations

This commit is contained in:
Anton Lavrenov 2020-01-27 13:41:18 -05:00
parent 7f62ccf620
commit e112c14852
4 changed files with 8 additions and 5 deletions

View File

@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## Not released:
* Fix line with tension calculations
## 4.1.2 - 2020-01-08
* Fix possible `NaN` in content calculations

View File

@ -9847,7 +9847,7 @@
points[1]
], this._getTensionPoints(), [
points[points.length - 2],
points[points.length - 2]
points[points.length - 1]
]);
}
else {

View File

@ -199,8 +199,8 @@ export class Line<Config extends LineConfig = LineConfig> extends Shape<
points[0],
points[1],
...this._getTensionPoints(),
points[points.length - 1],
points[points.length - 2]
points[points.length - 2],
points[points.length - 1]
];
} else {
points = this.points();

View File

@ -291,6 +291,7 @@ suite('Line', function() {
test('getClientRect with tension', function() {
var stage = addStage();
stage.draggable(true);
var layer = new Konva.Layer();
var line = new Konva.Line({
@ -298,7 +299,7 @@ suite('Line', function() {
y: 0,
points: [75, 75, 100, 200, 300, 140],
tension: 0.5,
stroke: '#0f0'
stroke: '#0f0',
});
layer.add(line);
@ -311,7 +312,7 @@ suite('Line', function() {
assert.equal(client.x, 56, 'check x');
assert.equal(client.y, 74, 'check y');
assert.equal(client.width, 245, 'check width');
assert.equal(client.height, 227, 'check height');
assert.equal(client.height, 147, 'check height');
});
test('getClientRect with low number of points', function() {