aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-07-26 09:17:34 +0100
committerwout <wout@impinc.co.uk>2013-07-26 09:17:34 +0100
commit21d6c0b30a530ce7746f789921c7135079f43338 (patch)
treee31f12819b83222cccdaaebbb171e800e97ffff5 /src
parent0685d55d3125f212975807f540520cffb663d9a8 (diff)
downloadsvg.js-21d6c0b30a530ce7746f789921c7135079f43338.tar.gz
svg.js-21d6c0b30a530ce7746f789921c7135079f43338.zip
Added support for CommonJS and AMD, bunped to v0.300.31
Diffstat (limited to 'src')
-rw-r--r--src/bbox.js3
-rw-r--r--src/doc.js2
-rw-r--r--src/element.js6
-rw-r--r--src/loader.js6
-rw-r--r--src/number.js3
5 files changed, 15 insertions, 5 deletions
diff --git a/src/bbox.js b/src/bbox.js
index b05e90c..603b6c9 100644
--- a/src/bbox.js
+++ b/src/bbox.js
@@ -57,5 +57,4 @@ SVG.extend(SVG.BBox, {
return b
}
-})
-
+}) \ No newline at end of file
diff --git a/src/doc.js b/src/doc.js
index 98ba91d..0a60f99 100644
--- a/src/doc.js
+++ b/src/doc.js
@@ -94,4 +94,4 @@ SVG.extend(SVG.Doc, {
.style('top', (-pos.f % 1) + 'px')
}
-})
+}) \ No newline at end of file
diff --git a/src/element.js b/src/element.js
index e6a7cd7..630b4a8 100644
--- a/src/element.js
+++ b/src/element.js
@@ -161,6 +161,10 @@ SVG.extend(SVG.Element, {
if (SVG.Color.test(v) || SVG.Color.isRgb(v))
v = new SVG.Color(v)
+ /* ensure correct numeric values */
+ else if (typeof v === 'number')
+ v = new SVG.Number(v)
+
/* parse array values */
else if (Array.isArray(v))
v = new SVG.Array(v)
@@ -249,7 +253,7 @@ SVG.extend(SVG.Element, {
/* add translation */
if (o.x != 0 || o.y != 0)
- transform.push('translate(' + o.x / o.scaleX + ' ' + o.y / o.scaleY + ')')
+ transform.push('translate(' + new SVG.Number(o.x / o.scaleX) + ' ' + new SVG.Number(o.y / o.scaleY) + ')')
/* add offset translation */
if (this._offset && this._offset.x != 0 && this._offset.y != 0)
diff --git a/src/loader.js b/src/loader.js
new file mode 100644
index 0000000..80644d8
--- /dev/null
+++ b/src/loader.js
@@ -0,0 +1,6 @@
+
+// Use AMD or CommonJS if either is present
+if (typeof define === 'function' && define.amd)
+ define(function() { return SVG })
+else if (typeof exports !== 'undefined')
+ exports.SVG = SVG \ No newline at end of file
diff --git a/src/number.js b/src/number.js
index e45a8c6..ae3c120 100644
--- a/src/number.js
+++ b/src/number.js
@@ -8,7 +8,8 @@ SVG.Number = function(value) {
/* parse value */
switch(typeof value) {
case 'number':
- this.value = value
+ /* ensure a valid numeric value */
+ this.value = isNaN(value) ? 0 : !isFinite(value) ? (value < 0 ? Number.MIN_VALUE : Number.MAX_VALUE) : value
break
case 'string':
var match = value.match(SVG.regex.unit)