Skip to content

Commit 70ad831

Browse files
fix(lines): curves distorted when it's zero value (#195)
* revert: revert old lineStyle config to maintain compatibility * fix(lines): curves distorted when it's zero value
1 parent 7f331be commit 70ad831

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/jsvectormap/src/js/core/repositionLines.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ export default function repositionLines() {
1313
if (startMarker && endMarker) {
1414
const { x: x1, y: y1 } = this.getMarkerPosition(startMarker.config)
1515
const { x: x2, y: y2 } = this.getMarkerPosition(endMarker.config)
16+
const curvatureOption = line._options.curvature == 0
17+
? 0
18+
: line._options.curvature || curvature
1619

1720
const midX = (x1 + x2) / 2
1821
const midY = (y1 + y2) / 2
19-
const curveX = midX + (line._options.curvature || curvature) * (y2 - y1)
20-
const curveY = midY - (line._options.curvature || curvature) * (x2 - x1)
22+
const curveX = midX + curvatureOption * (y2 - y1)
23+
const curveY = midY - curvatureOption * (x2 - x1)
2124

2225
line.setStyle({
2326
d: `M${x1},${y1} Q${curveX},${curveY} ${x2},${y2}`,

0 commit comments

Comments
 (0)