diff --git a/src/components/SVG/path.js b/src/components/SVG/path.js index 68592fa..178e46e 100644 --- a/src/components/SVG/path.js +++ b/src/components/SVG/path.js @@ -88,14 +88,16 @@ class Path { relative = relative === undefined ? this.relative : relative; if (cx === undefined || cy === undefined) { const command = relative ? 't' : 'T'; - this.pathParts.push(`${command} ${x},${y}`); + this.pathParts.push(`${command}${x},${y}`); } else { const command = relative ? 'q' : 'Q'; this.pathParts.push(`${command}${cx},${cy} ${x},${y}`); } - this.currentPosition.x = relative ? this.currentPosition.x + x : x; - this.currentPosition.y = relative ? this.currentPosition.y + y : y; + this.currentPosition = { + x: relative ? this.currentPosition.x + x : x, + y: relative ? this.currentPosition.y + y : y + }; return this; } diff --git a/src/components/SVG/path.test.js b/src/components/SVG/path.test.js index f41d89c..2374a39 100644 --- a/src/components/SVG/path.test.js +++ b/src/components/SVG/path.test.js @@ -24,7 +24,12 @@ describe('Path', () => { [ 'cubicCurveTo', { cx1: 5, cy1: 6, cx2: 10, cy2: 11, x: 15, y: 16 }, 'C5,6 10,11 15,16' ], [ 'cubicCurveTo', { cx2: 10, cy2: 11, x: 15, y: 16 }, 'S10,11 15,16' ], [ 'cubicCurveTo', { cx1: 5, cy1: 6, cx2: 10, cy2: 11, x: 15, y: 16, relative: true }, 'c5,6 10,11 15,16' ], - [ 'cubicCurveTo', { cx2: 10, cy2: 11, x: 15, y: 16, relative: true }, 's10,11 15,16' ] + [ 'cubicCurveTo', { cx2: 10, cy2: 11, x: 15, y: 16, relative: true }, 's10,11 15,16' ], + // quadraticCurveTo + [ 'quadraticCurveTo', { cx: 5, cy: 6, x: 10, y: 11 }, 'Q5,6 10,11' ], + [ 'quadraticCurveTo', { x: 10, y: 11 }, 'T10,11' ], + [ 'quadraticCurveTo', { cx: 5, cy: 6, x: 10, y: 11, relative: true }, 'q5,6 10,11' ], + [ 'quadraticCurveTo', { x: 10, y: 11, relative: true }, 't10,11' ] ].forEach(([ cmd, args, str ], i) => ( test(`case #${ i }`, () => { const path = new Path();