diff options
author | wout <wout@impinc.co.uk> | 2014-08-28 18:44:14 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-08-28 18:44:14 +0200 |
commit | 8789391f036ffded3ac919d62ee652e7cae15c5c (patch) | |
tree | cbb130ca8206e1b66057a5652a775d16e3aa3c36 /dist/svg.js | |
parent | 7b8e6f1d5afe2472cd1245f9bb73b6d59238e541 (diff) | |
download | svg.js-8789391f036ffded3ac919d62ee652e7cae15c5c.tar.gz svg.js-8789391f036ffded3ac919d62ee652e7cae15c5c.zip |
Fixed instantiation issue in SVG.Number
Diffstat (limited to 'dist/svg.js')
-rwxr-xr-x | dist/svg.js | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/dist/svg.js b/dist/svg.js index 5c2a59c..af662fa 100755 --- a/dist/svg.js +++ b/dist/svg.js @@ -6,7 +6,7 @@ * @copyright Wout Fierens <wout@impinc.co.uk> * @license MIT * -* BUILT: Mon Aug 25 2014 09:53:20 GMT+0200 (CEST) +* BUILT: Thu Aug 28 2014 18:38:34 GMT+0200 (CEST) */; (function(root, factory) { @@ -745,31 +745,31 @@ SVG.extend(SVG.PathArray, { // Module for unit convertions SVG.Number = SVG.invent({ // Initialize - create: function(value) { - // Initialize defaults + create: function(value, unit) { + // initialize defaults this.value = 0 - this.unit = '' + this.unit = unit || '' - // Parse value + // parse value if (typeof value === 'number') { - // Ensure a valid numeric value + // ensure a valid numeric value this.value = isNaN(value) ? 0 : !isFinite(value) ? (value < 0 ? -3.4e+38 : +3.4e+38) : value } else if (typeof value === 'string') { - var match = value.match(SVG.regex.unit) + unit = value.match(SVG.regex.unit) - if (match) { - // Make value numeric - this.value = parseFloat(match[1]) + if (unit) { + // make value numeric + this.value = parseFloat(unit[1]) - // Normalize - if (match[2] == '%') + // normalize + if (unit[2] == '%') this.value /= 100 - else if (match[2] == 's') + else if (unit[2] == 's') this.value *= 1000 - // Store unit - this.unit = match[2] + // store unit + this.unit = unit[2] } } else { @@ -798,9 +798,7 @@ SVG.Number = SVG.invent({ } // Add number , plus: function(number) { - this.value = this + new SVG.Number(number) - - return this + return new SVG.Number(this + new SVG.Number(number), this.unit) } // Subtract number , minus: function(number) { @@ -808,15 +806,11 @@ SVG.Number = SVG.invent({ } // Multiply number , times: function(number) { - this.value = this * new SVG.Number(number) - - return this + return new SVG.Number(this * new SVG.Number(number), this.unit) } // Divide number , divide: function(number) { - this.value = this / new SVG.Number(number) - - return this + return new SVG.Number(this / new SVG.Number(number), this.unit) } // Convert to different unit , to: function(unit) { |