Created
May 13, 2014 14:13
-
-
Save cdata/625608c3d9a1c2082140 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| li { | |
| display: block; | |
| position: relative; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="http://code.jquery.com/jquery-2.1.0.min.js"></script> | |
| <script src="http://julian.com/research/velocity/build/jquery.velocity.min.js"></script> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/react/0.10.0/react-with-addons.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Item = React.createClass({ | |
| componentWillEnter: function (cb) { | |
| $(this.getDOMNode()).css({ left: '10px', opacity: 0 }).velocity({ left: 0, opacity: 1 }, 'easeInOutQuad', cb); | |
| }, | |
| componentWillLeave: function (cb) { | |
| $(this.getDOMNode()).velocity({ left: '10px', opacity: 0 }, 'easeInOutQuint', cb); | |
| }, | |
| render: function () { | |
| return React.DOM.li({}, this.props.content + ' mod ' + Math.random()); | |
| } | |
| }); | |
| var App = React.createClass({ | |
| getInitialState: function () { | |
| return { items: 5 }; | |
| }, | |
| componentDidMount: function () { | |
| var that = this; | |
| window.setInterval(function () { | |
| that.setState({ items: Math.floor(Math.random() * 100) }); | |
| }, 50); | |
| }, | |
| render: function () { | |
| var items = []; | |
| for (var i = 0; i < this.state.items; ++i) { | |
| items.push(Item({ content: 'Item ' + i }, null)); | |
| } | |
| return React.addons.TransitionGroup({ | |
| transitionName: 'foo', | |
| component: React.DOM.ul | |
| }, items); | |
| } | |
| }); | |
| React.renderComponent(App(), document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment