summaryrefslogtreecommitdiffstats
path: root/src/element.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-01-01 21:39:25 +0100
committerwout <wout@impinc.co.uk>2013-01-01 21:39:25 +0100
commit88987d60c456f1e686edd226f4ccb45e35142cd7 (patch)
tree719bd1c6ea1e18bae81ea9a8083742184eb422e9 /src/element.js
parent5e7c26e9423f3c543e04bc9a11656125ec7bf8ca (diff)
downloadsvg.js-88987d60c456f1e686edd226f4ccb45e35142cd7.tar.gz
svg.js-88987d60c456f1e686edd226f4ccb45e35142cd7.zip
Replaced clip() in favor of mask()
Some browsers had issues with clipping, masking was a better option.
Diffstat (limited to 'src/element.js')
-rw-r--r--src/element.js44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/element.js b/src/element.js
index 5db42b3..aaa6010 100644
--- a/src/element.js
+++ b/src/element.js
@@ -40,21 +40,35 @@ SVG.extend(SVG.Element, {
// clone element
clone: function() {
- var c,
- n = this.node.nodeName;
-
- // invoke shape method with shape-specific arguments
- 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]();
-
- // copy translations
+ var c;
+
+ // if this is a wrapped shape
+ if (this instanceof Wrap) {
+ // build new wrapped shape
+ c = this.parent[this.child.node.nodeName]();
+
+ // copy child attributes and transformations
+ c.child.trans = this.child.trans;
+ c.child.attr(this.child.attrs).transform({});
+
+ } else {
+ var n = this.node.nodeName;
+
+ // invoke shape method with shape-specific arguments
+ 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) :
+ n == 'g' ?
+ this.parent.group() :
+ this.parent[n]();
+ }
+
+ // copy transformations
c.trans = this.trans;
// apply attributes and translations