summaryrefslogtreecommitdiffstats
path: root/src/sugar.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-02-02 11:14:21 +0100
committerwout <wout@impinc.co.uk>2013-02-02 11:14:21 +0100
commit7323d05f9d09141ec81dcd78d09bdba714c1c5dd (patch)
tree191d1a1e74f8f6b2ab5b7e473897e5daf8759dde /src/sugar.js
parent4a7588695a1b385f41acd6cbbfaf76b38b2a1439 (diff)
downloadsvg.js-7323d05f9d09141ec81dcd78d09bdba714c1c5dd.tar.gz
svg.js-7323d05f9d09141ec81dcd78d09bdba714c1c5dd.zip
Reworked SVG.Container inheritance
Diffstat (limited to 'src/sugar.js')
-rw-r--r--src/sugar.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/sugar.js b/src/sugar.js
index bd8930e..d53054e 100644
--- a/src/sugar.js
+++ b/src/sugar.js
@@ -54,10 +54,17 @@ var _colorPrefix = function(type, attr) {
},
// Opacity
opacity: function(value) {
- if (['rect', 'ellipse', 'polygon', 'path', 'polyline', 'line', 'text'].indexOf(this.type) > -1)
- this.attr({ 'fill-opacity': value, 'stroke-opacity': value });
- else
- this.attr('opacity', value);
+ if (['rect', 'ellipse', 'polygon', 'path', 'polyline', 'line', 'text'].indexOf(this.type) > -1) {
+ if (value == null)
+ return this.attr('fill-opacity');
+ else
+ this.attr({ 'fill-opacity': value, 'stroke-opacity': value });
+ } else {
+ if (value == null)
+ return this.attr('opacity');
+ else
+ this.attr('opacity', value);
+ }
return this;
}