mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-07 08:45:00 +00:00
Fix Polygon and Polyline
This commit is contained in:
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
import React, {Component, PropTypes} from 'react';
|
import React, {Component, PropTypes} from 'react';
|
||||||
import Path from './Path';
|
import Path from './Path';
|
||||||
import {pathProps} from '../lib/props';
|
import {pathProps} from '../lib/props';
|
||||||
|
import extractPolyPoints from '../lib/extract/extractPolyPoints';
|
||||||
|
|
||||||
export default class extends Component{
|
export default class extends Component{
|
||||||
static displayName = 'Polygon';
|
static displayName = 'Polygon';
|
||||||
@@ -26,7 +27,7 @@ export default class extends Component{
|
|||||||
return <Path
|
return <Path
|
||||||
ref={ele => {this.root = ele;}}
|
ref={ele => {this.root = ele;}}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
d={`M${points.trim().replace(/\s+/g, 'L')}z`}
|
d={`M${extractPolyPoints(points)}z`}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, {Component, PropTypes} from 'react';
|
import React, {Component, PropTypes} from 'react';
|
||||||
import Path from './Path';
|
import Path from './Path';
|
||||||
import {pathProps} from '../lib/props';
|
import {pathProps} from '../lib/props';
|
||||||
|
import extractPolyPoints from '../lib/extract/extractPolyPoints';
|
||||||
|
|
||||||
export default class extends Component{
|
export default class extends Component{
|
||||||
static displayName = 'Polyline';
|
static displayName = 'Polyline';
|
||||||
@@ -26,7 +27,7 @@ export default class extends Component{
|
|||||||
return <Path
|
return <Path
|
||||||
ref={ele => {this.root = ele;}}
|
ref={ele => {this.root = ele;}}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
d={`M${points.trim().replace(/\s+/g, 'L')}`}
|
d={`M${extractPolyPoints(points)}`}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
export default function (polyPoints) {
|
||||||
|
return polyPoints.replace(/-/, ' -').split(/(?:\s+|\s*,)\s*/g).join(' ');
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user