Fix Polygon and Polyline

This commit is contained in:
Horcrux
2017-04-04 11:56:38 +08:00
parent 9df76e5668
commit e3b2f4c71a
3 changed files with 8 additions and 2 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
import React, {Component, PropTypes} from 'react';
import Path from './Path';
import {pathProps} from '../lib/props';
import extractPolyPoints from '../lib/extract/extractPolyPoints';
export default class extends Component{
static displayName = 'Polygon';
@@ -26,7 +27,7 @@ export default class extends Component{
return <Path
ref={ele => {this.root = ele;}}
{...this.props}
d={`M${points.trim().replace(/\s+/g, 'L')}z`}
d={`M${extractPolyPoints(points)}z`}
/>;
}
}
+2 -1
View File
@@ -1,6 +1,7 @@
import React, {Component, PropTypes} from 'react';
import Path from './Path';
import {pathProps} from '../lib/props';
import extractPolyPoints from '../lib/extract/extractPolyPoints';
export default class extends Component{
static displayName = 'Polyline';
@@ -26,7 +27,7 @@ export default class extends Component{
return <Path
ref={ele => {this.root = ele;}}
{...this.props}
d={`M${points.trim().replace(/\s+/g, 'L')}`}
d={`M${extractPolyPoints(points)}`}
/>;
}
}
+4
View File
@@ -0,0 +1,4 @@
export default function (polyPoints) {
return polyPoints.replace(/-/, ' -').split(/(?:\s+|\s*,)\s*/g).join(' ');
}