SvgImporter: Shorten percentage code.

This commit is contained in:
Jürg Lehni 2012-11-08 09:41:58 -08:00
parent b04f852667
commit 1376d75e61

View file

@ -424,9 +424,8 @@ new function() {
break; break;
// http://www.w3.org/TR/SVG/pservers.html#StopElementOffsetAttribute // http://www.w3.org/TR/SVG/pservers.html#StopElementOffsetAttribute
case 'offset': case 'offset':
var isPercentage = value[value.length - 1] == '%'; var percentage = value.match(/(.*)%$/);
value = parseFloat(isPercentage ? value.slice(0, -1) : value, 10); item.setRampPoint(percentage ? percentage[1] / 100 : value);
item.setRampPoint(isPercentage ? value / 100 : value);
break; break;
case 'xlink:href': case 'xlink:href':
var definition = definitions[value.substr(1)]; var definition = definitions[value.substr(1)];