diff options
author | wout <wout@impinc.co.uk> | 2014-06-21 21:19:06 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-06-21 21:19:06 +0200 |
commit | 0bb294ad9189797014b1e1bf55e41ca4b1ead19e (patch) | |
tree | 4e4c5004beea90033e9fe80846c9a4c0b2b2ba30 /src/arrange.js | |
parent | 629a01b3bbf057eae7e0599433bbbcb28acd8587 (diff) | |
download | svg.js-0bb294ad9189797014b1e1bf55e41ca4b1ead19e.tar.gz svg.js-0bb294ad9189797014b1e1bf55e41ca4b1ead19e.zip |
Back on track with the specs
Diffstat (limited to 'src/arrange.js')
-rwxr-xr-x | src/arrange.js | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/arrange.js b/src/arrange.js index 5c4e878..b6721b4 100755 --- a/src/arrange.js +++ b/src/arrange.js @@ -20,8 +20,17 @@ SVG.extend(SVG.Element, { } // Send given element one step forward , forward: function() { - var i = this.position() - return this.parent().removeElement(this).put(this, i + 1) + var i = this.position() + 1 + , p = this.parent() + + // Move node one step forward + p.removeElement(this).add(this, i) + + // Make sure defs node is always at the top + if (p instanceof SVG.Doc) + p.node.appendChild(p.defs().node) + + return this } // Send given element one step backward , backward: function() { @@ -34,7 +43,16 @@ SVG.extend(SVG.Element, { } // Send given element all the way to the front , front: function() { - return this.parent().removeElement(this).put(this) + var p = this.parent() + + // Move node forward + p.node.appendChild(this.node) + + // Make sure defs node is always at the top + if (p instanceof SVG.Doc) + p.node.appendChild(p.defs().node) + + return this } // Send given element all the way to the back , back: function() { |