From 5ce846b045edfa4db20049706314cdb37ae5acfc Mon Sep 17 00:00:00 2001 From: Harti Date: Tue, 7 Jul 2015 11:13:45 +0200 Subject: [PATCH] [DRAFT!] Add an optional attribute to manipulate the children order **WARNING!** This is only a draft to enable easier implementation for the project maintainers. Being short on time, I was unable to compile it (I'm pretty new to the ES6 sort of coding), therefore this is **not tested**. This is only to give you an idea of what I was hinting at in issue #7, maybe it becomes more clear what I was trying to achieve. --- src/shuffle.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/shuffle.js b/src/shuffle.js index 5c7ec76..f099c03 100644 --- a/src/shuffle.js +++ b/src/shuffle.js @@ -25,8 +25,12 @@ const Clones = React.createClass({ scale={this.props.scale} duration={this.props.duration}/>); }); - return children.sort((a, b) => - (a.key < b.key) ? -1 : (a.key > b.key) ? 1 : 0 + return children.sort((a, b) => { + a.order = a.props['shuffle-order'] || a.key; + b.order = b.props['shuffle-order'] || b.key; + + (a.order < b.order) ? -1 : (a.order > b.order) ? 1 : 0 + } ); },