diff options
author | wout <wout@impinc.co.uk> | 2013-01-04 19:12:16 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-01-04 19:12:16 +0100 |
commit | 2380c67d4ddded556617760b4b3cb38a1d7758e2 (patch) | |
tree | c0bd5ee57a4c83e5d8860becba7766188344eda3 /src/arrange.js | |
parent | 40de19951d0a4218ee2625fa9a1a69f04e79692d (diff) | |
download | svg.js-2380c67d4ddded556617760b4b3cb38a1d7758e2.tar.gz svg.js-2380c67d4ddded556617760b4b3cb38a1d7758e2.zip |
Made code more readable and included docs
Diffstat (limited to 'src/arrange.js')
-rw-r--r-- | src/arrange.js | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/arrange.js b/src/arrange.js index ec06591..63ac659 100644 --- a/src/arrange.js +++ b/src/arrange.js @@ -1,55 +1,48 @@ +// ### This module adds backward / forward functionality to elements. -// add backward / forward functionality to elements +// SVG.extend(SVG.Element, { - - // get all siblings, including myself + // Get all siblings, including myself siblings: function() { return this.parent.children(); }, - - // get the curent position siblings + // Get the curent position siblings position: function() { return this.siblings().indexOf(this); }, - - // get the next element + // Get the next element (will return null if there is none) next: function() { return this.siblings()[this.position() + 1]; }, - - // get the next element + // Get the next element (will return null if there is none) previous: function() { return this.siblings()[this.position() - 1]; }, - - // send given element one step forwards + // Send given element one step forward forward: function() { return this.parent.remove(this).put(this, this.position() + 1); }, - - // send given element one step backwards + // Send given element one step backward backward: function() { - var i, p = this.parent.level(); + var i, parent = this.parent.level(); i = this.position(); if (i > 1) - p.remove(this).add(this, i - 1); + parent.remove(this).add(this, i - 1); return this; }, - - // send given element all the way to the front + // Send given element all the way to the front front: function() { return this.parent.remove(this).put(this); }, - - // send given element all the way to the back + // Send given element all the way to the back back: function() { - var p = this.parent.level(); + var parent = this.parent.level(); if (this.position() > 1) - p.remove(this).add(this, 0); + parent.remove(this).add(this, 0); return this; } |