Extend and improve propTypes. Optimize javascript hidden classes and inline caching in V8.

Add lengthAdjust and textLength text / tspan attributes.
This commit is contained in:
Mikael Sand
2017-07-25 04:07:04 +03:00
parent 4cfdfd9bf2
commit fddb4008d1
5 changed files with 137 additions and 49 deletions
+108 -10
View File
@@ -48,6 +48,16 @@ const strokeProps = {
strokeMiterlimit: numberProp
};
const pathProps = {
...fillProps,
...strokeProps,
...clipProps,
...transformProps,
...responderProps,
...touchableProps,
...definationProps
};
// normal | italic | oblique | inherit
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/font-style
const fontStyle = PropTypes.oneOf(['normal', 'italic', 'oblique']);
@@ -127,6 +137,102 @@ const fontProps = {
font
};
/*
Name Value Initial value Animatable
lengthAdjust spacing | spacingAndGlyphs spacing yes
https://svgwg.org/svg2-draft/text.html#TextElementLengthAdjustAttribute
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/lengthAdjust
*/
const lengthAdjust = PropTypes.oneOf(['spacing', 'spacingAndGlyphs']);
/*
Name Value Initial value Animatable
textLength <length> | <percentage> | <number> See below yes
https://svgwg.org/svg2-draft/text.html#TextElementTextLengthAttribute
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/textLength
*/
const textLength = PropTypes.string;
const textSpecificProps = {
...pathProps,
...fontProps,
lengthAdjust,
textLength,
}
// https://svgwg.org/svg2-draft/text.html#TSpanAttributes
const textProps = {
...textSpecificProps,
dx: PropTypes.string,
dy: PropTypes.string,
}
/*
Name
side
Value
left | right
initial value
left
Animatable
yes
https://svgwg.org/svg2-draft/text.html#TextPathElementSideAttribute
*/
const side = PropTypes.oneOf(['left', 'right']);
/*
Name
startOffset
Value
<length> | <percentage> | <number>
initial value
0
Animatable
yes
https://svgwg.org/svg2-draft/text.html#TextPathElementStartOffsetAttribute
https://developer.mozilla.org/en/docs/Web/SVG/Element/textPath
*/
const startOffset = PropTypes.string;
/*
Name
method
Value
align | stretch
initial value
align
Animatable
yes
https://svgwg.org/svg2-draft/text.html#TextPathElementMethodAttribute
https://developer.mozilla.org/en/docs/Web/SVG/Element/textPath
*/
const method = PropTypes.oneOf(['align', 'stretch']);
/*
Name
spacing
Value
auto | exact
initial value
exact
Animatable
yes
https://svgwg.org/svg2-draft/text.html#TextPathElementSpacingAttribute
https://developer.mozilla.org/en/docs/Web/SVG/Element/textPath
*/
const spacing = PropTypes.oneOf(['auto', 'exact']);
// https://svgwg.org/svg2-draft/text.html#TextPathAttributes
// https://developer.mozilla.org/en/docs/Web/SVG/Element/textPath
const textPathProps = {
...textSpecificProps,
href: PropTypes.string.isRequired,
startOffset,
method,
spacing,
side,
}
const transformProps = {
scale: numberProp,
scaleX: numberProp,
@@ -147,21 +253,13 @@ const transformProps = {
transform: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
};
const pathProps = {
...fillProps,
...strokeProps,
...clipProps,
...transformProps,
...responderProps,
...touchableProps,
...definationProps
};
export {
numberProp,
fillProps,
strokeProps,
fontProps,
textProps,
textPathProps,
clipProps,
pathProps,
responderProps,