mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-07 00:42:31 +00:00
remove unsued code
This commit is contained in:
@@ -1,49 +0,0 @@
|
|||||||
/**
|
|
||||||
* Format potential percentage props
|
|
||||||
*
|
|
||||||
* convert somet props like those
|
|
||||||
* width="50%"
|
|
||||||
* height="500"
|
|
||||||
*
|
|
||||||
* to
|
|
||||||
* {
|
|
||||||
* width: {
|
|
||||||
* percentage: true,
|
|
||||||
* value: 0.5
|
|
||||||
* },
|
|
||||||
* height: {
|
|
||||||
* percentage: false,
|
|
||||||
* value: 500
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
import _ from 'lodash';
|
|
||||||
import percentToFloat from './percentToFloat';
|
|
||||||
|
|
||||||
function percentageTransform(value) {
|
|
||||||
if (typeof value === 'number') {
|
|
||||||
return {
|
|
||||||
percentage: false,
|
|
||||||
value
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let float = percentToFloat(value);
|
|
||||||
|
|
||||||
return {
|
|
||||||
percentage: float !== +value,
|
|
||||||
value: float
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function (props, list) {
|
|
||||||
return _.reduce(list, (prev, name) => {
|
|
||||||
if (!_.isNil(props[name])) {
|
|
||||||
prev[name] = percentageTransform(props[name]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return prev;
|
|
||||||
}, {});
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import percentToFloat from './percentToFloat';
|
|
||||||
let percentReg = /%/;
|
|
||||||
|
|
||||||
export default function (...args) {
|
|
||||||
let hasPercent = percentReg.test(args.join(''));
|
|
||||||
if (hasPercent) {
|
|
||||||
return args.map(arg => {
|
|
||||||
return function (base) {
|
|
||||||
return percentReg.test(arg) ? percentToFloat(arg) * base : +arg;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user