diff options
author | wout <wout@impinc.co.uk> | 2012-12-31 14:43:26 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2012-12-31 14:43:26 +0100 |
commit | 8dbe3599dd9b80738c4124f7e71bc12e763c50dc (patch) | |
tree | 97b9d3a3c85ae2cabd17702b74388f219accb2ef /src/arrange.js | |
parent | f210affa28f5ad2a92a12d8ca17c7ae6083b1d98 (diff) | |
download | svg.js-8dbe3599dd9b80738c4124f7e71bc12e763c50dc.tar.gz svg.js-8dbe3599dd9b80738c4124f7e71bc12e763c50dc.zip |
Added position()
Diffstat (limited to 'src/arrange.js')
-rw-r--r-- | src/arrange.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/arrange.js b/src/arrange.js index ac53e43..ff255be 100644 --- a/src/arrange.js +++ b/src/arrange.js @@ -7,6 +7,11 @@ SVG.extend(SVG.Element, { 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); @@ -18,7 +23,7 @@ SVG.extend(SVG.Element, { 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); @@ -33,11 +38,9 @@ SVG.extend(SVG.Element, { // 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; |