Skip to content

Commit 685c7a0

Browse files
committed
Improve the example comprehensiveness
1 parent 9732915 commit 685c7a0

File tree

5 files changed

+403
-324
lines changed

5 files changed

+403
-324
lines changed

examples/buttons.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/** @jsx React.DOM */
2+
3+
var transformers = require('../');
4+
var React = require('react');
5+
6+
var PrintX = React.createClass({
7+
render: function() {
8+
return <div>{this.props.x}</div>;
9+
}
10+
});
11+
12+
var App = React.createClass({
13+
getInitialState: function() {
14+
return {on: 0};
15+
},
16+
turnOn: function() {
17+
this.setState({on:1});
18+
},
19+
turnOff: function() {
20+
this.setState({on:0});
21+
},
22+
render: function() {
23+
var SmoothPrintX = transformers.inertial(PrintX, {x:'number'}, 1000);
24+
return (
25+
<div>
26+
<SmoothPrintX x={this.state.on ? 100 : 0}/>
27+
<button onClick={this.turnOn}>On</button>
28+
<button onClick={this.turnOff}>Off</button>
29+
</div>
30+
);
31+
}
32+
});
33+
34+
React.renderComponent(<App/>, document.getElementById('buttons'));

0 commit comments

Comments
 (0)