mirror of
https://github.com/konvajs/konva.git
synced 2026-01-22 21:02:26 +08:00
fix calculations
This commit is contained in:
@@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## Not released:
|
## Not released:
|
||||||
|
|
||||||
|
* Fix line with tension calculations
|
||||||
|
|
||||||
## 4.1.2 - 2020-01-08
|
## 4.1.2 - 2020-01-08
|
||||||
|
|
||||||
* Fix possible `NaN` in content calculations
|
* Fix possible `NaN` in content calculations
|
||||||
|
|||||||
2
konva.js
2
konva.js
@@ -9847,7 +9847,7 @@
|
|||||||
points[1]
|
points[1]
|
||||||
], this._getTensionPoints(), [
|
], this._getTensionPoints(), [
|
||||||
points[points.length - 2],
|
points[points.length - 2],
|
||||||
points[points.length - 2]
|
points[points.length - 1]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -199,8 +199,8 @@ export class Line<Config extends LineConfig = LineConfig> extends Shape<
|
|||||||
points[0],
|
points[0],
|
||||||
points[1],
|
points[1],
|
||||||
...this._getTensionPoints(),
|
...this._getTensionPoints(),
|
||||||
points[points.length - 1],
|
points[points.length - 2],
|
||||||
points[points.length - 2]
|
points[points.length - 1]
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
points = this.points();
|
points = this.points();
|
||||||
|
|||||||
@@ -291,6 +291,7 @@ suite('Line', function() {
|
|||||||
|
|
||||||
test('getClientRect with tension', function() {
|
test('getClientRect with tension', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
|
stage.draggable(true);
|
||||||
var layer = new Konva.Layer();
|
var layer = new Konva.Layer();
|
||||||
|
|
||||||
var line = new Konva.Line({
|
var line = new Konva.Line({
|
||||||
@@ -298,7 +299,7 @@ suite('Line', function() {
|
|||||||
y: 0,
|
y: 0,
|
||||||
points: [75, 75, 100, 200, 300, 140],
|
points: [75, 75, 100, 200, 300, 140],
|
||||||
tension: 0.5,
|
tension: 0.5,
|
||||||
stroke: '#0f0'
|
stroke: '#0f0',
|
||||||
});
|
});
|
||||||
layer.add(line);
|
layer.add(line);
|
||||||
|
|
||||||
@@ -311,7 +312,7 @@ suite('Line', function() {
|
|||||||
assert.equal(client.x, 56, 'check x');
|
assert.equal(client.x, 56, 'check x');
|
||||||
assert.equal(client.y, 74, 'check y');
|
assert.equal(client.y, 74, 'check y');
|
||||||
assert.equal(client.width, 245, 'check width');
|
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() {
|
test('getClientRect with low number of points', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user