diff options
author | wout <wout@impinc.co.uk> | 2012-12-30 19:20:31 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2012-12-30 19:20:31 +0100 |
commit | 7d3e4c43a64cdb9ce19b71d8dc1783c0bc031d91 (patch) | |
tree | 05441a30fbac6ccdd9ee2cf91b3c583a5ab6e0a4 /src | |
parent | b663ead6ee026e4c7b6f3b971e2490222c4a3a1a (diff) | |
download | svg.js-7d3e4c43a64cdb9ce19b71d8dc1783c0bc031d91.tar.gz svg.js-7d3e4c43a64cdb9ce19b71d8dc1783c0bc031d91.zip |
Added hide() and show()
Diffstat (limited to 'src')
-rw-r--r-- | src/element.js | 14 | ||||
-rw-r--r-- | src/event.js | 21 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/element.js b/src/element.js index e7701ce..6eea786 100644 --- a/src/element.js +++ b/src/element.js @@ -159,6 +159,20 @@ SVG.extend(SVG.Element, { }; }, + // show element + show: function() { + this.node.style.display = ''; + + return this; + }, + + // hide element + hide: function() { + this.node.style.display = 'none'; + + return this; + }, + // private: find svg parent _parent: function(pt) { var e = this; diff --git a/src/event.js b/src/event.js index ca1d290..4f587d2 100644 --- a/src/event.js +++ b/src/event.js @@ -1,20 +1,15 @@ -var eventTypes = ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout', 'mousemove']; - -// generate events -for (var i = eventTypes.length - 1; i >= 0; i--) { - var t = eventTypes[i]; - +var eventTypes = ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout', 'mousemove'].forEach(function(e) { // add event to SVG.Elment - SVG.Element.prototype[t] = function(f) { - var e = this; - + SVG.Element.prototype[e] = function(f) { + var s = this; + // bind event to element rather than element node - this.node['on' + t] = function() { - return f.apply(e, arguments); + this.node['on' + e] = function() { + return f.apply(s, arguments); }; - + // return self return this; }; -};
\ No newline at end of file +}); |