diff options
author | wout <wout@impinc.co.uk> | 2012-12-31 14:33:53 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2012-12-31 14:33:53 +0100 |
commit | f210affa28f5ad2a92a12d8ca17c7ae6083b1d98 (patch) | |
tree | a14201741cfc920b9212995388f601bd5a6e5f3d /dist/svg.js | |
parent | 9f622f7b160fb977a4354eb0f775d4b53a2f7443 (diff) | |
download | svg.js-f210affa28f5ad2a92a12d8ca17c7ae6083b1d98.tar.gz svg.js-f210affa28f5ad2a92a12d8ca17c7ae6083b1d98.zip |
Added clone()
Diffstat (limited to 'dist/svg.js')
-rw-r--r-- | dist/svg.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/dist/svg.js b/dist/svg.js index 363e890..95464c6 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js v0.1-49-g7d3e4c4 - svg container element event group arrange defs clip mask gradient doc shape rect ellipse poly path image text sugar - svgjs.com/license */ +/* svg.js v0.1-50-g9f622f7 - svg container element event group arrange defs clip mask gradient doc shape rect ellipse poly path image text sugar - svgjs.com/license */ (function() { this.SVG = { @@ -180,7 +180,7 @@ }, // set element size to given width and height - size: function(w, h) { + size: function(w, h) { return this.attr({ width: w, height: h }); }, @@ -191,6 +191,24 @@ return this.move(x - b.width / 2, y - b.height / 2); }, + // clone element + clone: function() { + var c, + n = this.node.nodeName; + + c = n == 'rect' ? + this.parent[n](this.attrs.width, this.attrs.height) : + n == 'ellipse' ? + this.parent[n](this.attrs.rx * 2, this.attrs.ry * 2) : + n == 'image' ? + this.parent[n](this.src) : + n == 'text' ? + this.parent[n](this.content) : + this.parent[n](); + + return c.attr(this.attrs); + }, + // remove element remove: function() { return this.parent != null ? this.parent.remove(this) : void 0; @@ -798,7 +816,8 @@ // (re)load image load: function(u) { - return this.attr('xlink:href', u, SVG.xlink); + this.src = u; + return (u ? this.attr('xlink:href', u, SVG.xlink) : this); } }); |