summaryrefslogtreecommitdiffstats
path: root/src/arrange.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/arrange.js')
-rwxr-xr-xsrc/arrange.js24
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() {