From 189f009dbb28525f3eb2c0bb7a72312cb6fe4ba6 Mon Sep 17 00:00:00 2001 From: wout Date: Mon, 3 Feb 2014 21:59:15 +0100 Subject: Added second values to SVG.Number --- src/fx.js | 2 +- src/number.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/fx.js b/src/fx.js index 40f253b..e802455 100755 --- a/src/fx.js +++ b/src/fx.js @@ -18,7 +18,7 @@ SVG.extend(SVG.FX, { } /* ensure default duration and easing */ - d = d == null ? 1000 : d + d = d == null ? 1000 : new SVG.Number(d).valueOf() ease = ease || '<>' /* process values */ diff --git a/src/number.js b/src/number.js index 7218a50..697d1dc 100755 --- a/src/number.js +++ b/src/number.js @@ -21,6 +21,8 @@ SVG.Number = function(value) { /* normalize percent value */ if (match[2] == '%') this.value /= 100 + else if (match[2] == 's') + this.value *= 1000 /* store unit */ this.unit = match[2] @@ -39,7 +41,13 @@ SVG.Number = function(value) { SVG.extend(SVG.Number, { // Stringalize toString: function() { - return (this.unit == '%' ? ~~(this.value * 1e8) / 1e6 : this.value) + this.unit + return ( + this.unit == '%' ? + ~~(this.value * 1e8) / 1e6: + this.unit == 's' ? + this.value / 1e3 : + this.value + ) + this.unit } , // Convert to primitive valueOf: function() { -- cgit v1.2.3