From 5e7c26e9423f3c543e04bc9a11656125ec7bf8ca Mon Sep 17 00:00:00 2001 From: wout Date: Mon, 31 Dec 2012 16:16:05 +0100 Subject: Added each(), next(), previous() and more --- src/arrange.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/arrange.js') diff --git a/src/arrange.js b/src/arrange.js index ff255be..ec06591 100644 --- a/src/arrange.js +++ b/src/arrange.js @@ -12,11 +12,19 @@ SVG.extend(SVG.Element, { return this.siblings().indexOf(this); }, + // get the next element + next: function() { + return this.siblings()[this.position() + 1]; + }, + + // get the next element + previous: function() { + return this.siblings()[this.position() - 1]; + }, + // send given element one step forwards forward: function() { - var i = this.siblings().indexOf(this); - - return this.parent.remove(this).put(this, i + 1); + return this.parent.remove(this).put(this, this.position() + 1); }, // send given element one step backwards -- cgit v1.2.3