diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/element.js | 7 | ||||
-rw-r--r-- | src/event.js | 2 | ||||
-rw-r--r-- | src/sugar.js | 9 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/element.js b/src/element.js index e1e69ec..ac06109 100644 --- a/src/element.js +++ b/src/element.js @@ -12,6 +12,9 @@ SVG.Element = function Element(node) { 'fill-opacity': 1, 'stroke-opacity': 1, 'stroke-width': 0, + fill: '#000', + stroke: '#000', + opacity: 1, x: 0, y: 0, cx: 0, @@ -258,6 +261,10 @@ SVG.extend(SVG.Element, { return this; }, + // Is element visible? + visible: function() { + return this.node.style.display != 'none'; + }, // Private: find svg parent by instance _parent: function(parent) { var element = this; diff --git a/src/event.js b/src/event.js index 8e485b6..d2222bf 100644 --- a/src/event.js +++ b/src/event.js @@ -10,6 +10,8 @@ 'mouseover', 'mouseout', 'mousemove', + 'mouseenter', + 'mouseleave', 'touchstart', 'touchend', 'touchmove', diff --git a/src/sugar.js b/src/sugar.js index a5725e1..bd8930e 100644 --- a/src/sugar.js +++ b/src/sugar.js @@ -51,6 +51,15 @@ var _colorPrefix = function(type, attr) { scaleX: x, scaleY: y == null ? x : y }); + }, + // 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); + + return this; } }); |