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 /dist/svg.js | |
parent | b663ead6ee026e4c7b6f3b971e2490222c4a3a1a (diff) | |
download | svg.js-7d3e4c43a64cdb9ce19b71d8dc1783c0bc031d91.tar.gz svg.js-7d3e4c43a64cdb9ce19b71d8dc1783c0bc031d91.zip |
Added hide() and show()
Diffstat (limited to 'dist/svg.js')
-rw-r--r-- | dist/svg.js | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/dist/svg.js b/dist/svg.js index 310719d..041beb7 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js v0.1-46-gf6724c3 - svg container element event group arrange defs clip gradient doc shape rect ellipse poly path image text sugar - svgjs.com/license */ +/* svg.js v0.1-48-gb663ead - svg container element event group arrange defs clip gradient doc shape rect ellipse poly path image text sugar - svgjs.com/license */ (function() { this.SVG = { @@ -309,6 +309,20 @@ }; }, + // 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; @@ -333,25 +347,21 @@ }); - 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; }; - }; + }); + SVG.G = function G() { this.constructor.call(this, SVG.create('g')); |