rect.backward();
```
+The arrange.js module brings some additional methods:
+
+```javascript
+// returns the position (a number) of the element between its siblings
+rect.position();
+```
+
+
_This functionality requires the arrange.js module which is included in the default distribution._
return this.parent.children();
},
+ // get the curent position siblings
+ position: function() {
+ return this.siblings().indexOf(this);
+ },
+
// send given element one step forwards
forward: function() {
var i = this.siblings().indexOf(this);
backward: function() {
var i, p = this.parent.level();
- i = this.siblings().indexOf(this);
+ i = this.position();
if (i > 1)
p.remove(this).add(this, i - 1);
// send given element all the way to the back
back: function() {
- var i, p = this.parent.level();
+ var p = this.parent.level();
- i = this.siblings().indexOf(this);
-
- if (i > 1)
+ if (this.position() > 1)
p.remove(this).add(this, 0);
return this;
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.content) :
this.parent[n]();
- return c.attr(this.attrs);
+ // copy translations
+ c.trans = this.trans;
+
+ // apply attributes and translations
+ return c.attr(this.attrs).transform({});
},
// remove element