change circle radius percentage calculation

Change circle radius  percentage calculation.
Add example for percentage props for shape.
Remove unused document ref
This commit is contained in:
Horcrux
2016-04-27 16:45:58 +08:00
parent c2359616bf
commit 99ab08db25
8 changed files with 49 additions and 21 deletions

View File

@@ -1,5 +1,10 @@
let percentReg = /^(\-?\d+(?:\.\d+)?)(%?)$/;
export default function (percent) {
let matched = percent.match(percentReg);
if (!matched) {
console.warn(`\`${percent}\` is not a valid number or percentage string.`);
return 0;
}
return matched[2] ? matched[1] / 100 : +matched[1];
}