Skip to content

Commit

Permalink
[DRAFT!] Add an optional attribute to manipulate the children order
Browse files Browse the repository at this point in the history
**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 FormidableLabs#7, maybe it becomes more clear what I was trying to achieve.
  • Loading branch information
Harti committed Jul 7, 2015
1 parent 320cb4a commit 5ce846b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/shuffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
);
},

Expand Down

0 comments on commit 5ce846b

Please sign in to comment.