mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-21 06:15:15 +00:00
Implement strokeDasharray correctly.
Support units and percentages with whitespace separated and/or (possibly white-space surrounded) comma separated length lists.
This commit is contained in:
@@ -2,12 +2,12 @@ import _ from 'lodash';
|
||||
//noinspection JSUnresolvedVariable
|
||||
import React, {Children} from 'react';
|
||||
import TSpan from '../../elements/TSpan';
|
||||
import extractLengthList from './extractLengthList';
|
||||
|
||||
const fontRegExp = /^\s*((?:(?:normal|bold|italic)\s+)*)(?:(\d+(?:\.\d+)?[ptexm%])*(?:\s*\/.*?)?\s+)?\s*"?([^"]*)/i;
|
||||
const fontFamilyPrefix = /^[\s"']*/;
|
||||
const fontFamilySuffix = /[\s"']*$/;
|
||||
const spaceReg = /\s+/;
|
||||
const commaReg = /,/g;
|
||||
const commaReg = /\s*,\s*/g;
|
||||
|
||||
const cachedFontObjectsFromString = {};
|
||||
|
||||
@@ -85,18 +85,6 @@ export function extractFont(props) {
|
||||
return _.defaults(ownedFont, font);
|
||||
}
|
||||
|
||||
function parseSVGLengthList(delta) {
|
||||
if (typeof delta === 'string') {
|
||||
return delta.trim().replace(commaReg, ' ').split(spaceReg);
|
||||
} else if (typeof delta === 'number') {
|
||||
return [delta.toString()];
|
||||
} else if (delta && typeof delta.map === 'function') {
|
||||
return delta.map(d => `${d}`);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export default function(props, container) {
|
||||
const {
|
||||
x,
|
||||
@@ -110,11 +98,11 @@ export default function(props, container) {
|
||||
children
|
||||
} = props;
|
||||
|
||||
const positionX = parseSVGLengthList(x);
|
||||
const positionY = parseSVGLengthList(y);
|
||||
const deltaX = parseSVGLengthList(dx);
|
||||
const deltaY = parseSVGLengthList(dy);
|
||||
rotate = parseSVGLengthList(rotate);
|
||||
const positionX = extractLengthList(x);
|
||||
const positionY = extractLengthList(y);
|
||||
const deltaX = extractLengthList(dx);
|
||||
const deltaY = extractLengthList(dy);
|
||||
rotate = extractLengthList(rotate);
|
||||
|
||||
let content = null;
|
||||
if (typeof children === 'string' || typeof children === 'number') {
|
||||
|
||||
Reference in New Issue
Block a user