Skip to content

Commit dc4da35

Browse files
committed
Internal lib - Avoid NaN values in path creation
1 parent b4336dd commit dc4da35

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ export function calcMedian(arr) {
696696
export function createStraightPath(points) {
697697
let arr = [];
698698
for (let i = 0; i < points.length; i += 1) {
699-
arr.push(`${points[i].x},${points[i].y} `)
699+
arr.push(`${checkNaN(points[i].x)},${checkNaN(points[i].y)} `)
700700
}
701701
return arr.join(' ').trim()
702702
}
@@ -725,10 +725,10 @@ export function createSmoothPath(points, smoothing = 0.2) {
725725
function bezierCommand(point, i, a) {
726726
const cps = controlPoint(a[i - 1], a[i - 2], point);
727727
const cpe = controlPoint(point, a[i - 1], a[i + 1], true);
728-
return `C ${cps.x},${cps.y} ${cpe.x},${cpe.y} ${point.x},${point.y}`;
728+
return `C ${checkNaN(cps.x)},${checkNaN(cps.y)} ${checkNaN(cpe.x)},${checkNaN(cpe.y)} ${checkNaN(point.x)},${checkNaN(point.y)}`;
729729
}
730730
const d = points.filter(p => !!p).reduce((acc, point, i, a) => i === 0
731-
? `${point.x},${point.y} `
731+
? `${checkNaN(point.x)},${checkNaN(point.y)} `
732732
: `${acc} ${bezierCommand(point, i, a)} `
733733
, '');
734734

0 commit comments

Comments
 (0)