Skip to content

Commit

Permalink
Merge pull request #34 from react-component/1.0
Browse files Browse the repository at this point in the history
update 1.0.0
  • Loading branch information
jljsj33 authored Apr 13, 2017
2 parents 3b8386c + 722a9d2 commit 3fb3ead
Show file tree
Hide file tree
Showing 14 changed files with 401 additions and 471 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ notifications:
- [email protected]

node_js:
- 4.0.0
- 6.0.0

before_install:
- |
Expand Down
25 changes: 14 additions & 11 deletions examples/animating-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import React from 'react';
import ReactDom from 'react-dom';
import '../assets/animating-class.less';

const App = React.createClass({
getInitialState() {
return {
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
items: [{
children: '依次进入1',
key: 1,
Expand All @@ -27,24 +28,26 @@ const App = React.createClass({
key: 6,
}],
};
},
removeAll() {
}

removeAll = () => {
this.setState({
items: [],
});
},
}

render() {
return (
<div>
<QueueAnim>
{this.state.items.map((item) => <div key={item.key}>
{item.children}
</div>)}
{this.state.items.map((item) => <div key={item.key}>
{item.children}
</div>)}
</QueueAnim>
<button onClick={this.removeAll}>移出所有</button>
</div>
);
},
});
}
}

ReactDom.render(<App />, document.getElementById('__react-content'));
4 changes: 2 additions & 2 deletions examples/custom-ease.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React from 'react';
import ReactDom from 'react-dom';

ReactDom.render(
<div>
<QueueAnim ease={[0.42, 0, 0.58, 1]}>
<div style={{ height: 500 }}>
<QueueAnim ease={[0.175, 0.885, 0.32, 1.275]}>
<div key="1">div 1</div>
<div key="2">div 1</div>
<div key="3">div 1</div>
Expand Down
23 changes: 13 additions & 10 deletions examples/dialog-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ import ReactDom from 'react-dom';
import Dialog from 'rc-dialog';
import 'rc-dialog/assets/index.css';

const App = React.createClass({
getInitialState() {
return {
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
show: false,
};
},
onClick() {
}

onClick = () => {
this.setState({
show: true,
});
},
onClose() {
}
onClose = () => {
this.setState({
show: false,
});
},
}

render() {
let dialog;
if (this.state.show) {
Expand Down Expand Up @@ -57,7 +60,7 @@ const App = React.createClass({
<button onClick={this.onClick}>弹出框口</button>
</div>
);
},
});
}
}

ReactDom.render(<App />, document.getElementById('__react-content'));
43 changes: 23 additions & 20 deletions examples/dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import QueueAnim from 'rc-queue-anim';
import React from 'react';
import ReactDom from 'react-dom';

const App = React.createClass({
getInitialState() {
class App extends React.Component {
constructor(props) {
super(props);
this.index = 100;
return {
this.state = {
items: [{
children: '依次进入1',
key: 1,
Expand All @@ -27,16 +28,17 @@ const App = React.createClass({
key: 6,
}],
};
},
add() {
}

add = () => {
const items = this.state.items;
items.push({
children: '新节点',
key: this.index++,
});
this.setState({ items });
},
addTwo() {
}
addTwo = () => {
const items = this.state.items;
items.push({
children: '新节点',
Expand All @@ -47,8 +49,8 @@ const App = React.createClass({
key: this.index++,
});
this.setState({ items });
},
remove(key, e) {
}
remove = (key, e) => {
e.preventDefault();
const items = this.state.items;
const target = items.filter(item => item.key === key);
Expand All @@ -60,22 +62,22 @@ const App = React.createClass({
items.splice(index, 1);
}
this.setState({ items });
},
removeAll() {
}
removeAll = () => {
this.setState({
items: [],
});
},
removeAndAdd() {
}
removeAndAdd = () => {
const items = this.state.items;
items.splice(items.length - 1, 1);
items.push({
children: `新节点${Date.now()}`,
key: this.index++,
});
this.setState({ items });
},
removeAndAddTow() {
}
removeAndAddTow = () => {
const items = this.state.items;
items.splice(items.length - 1, 1);
items.splice(items.length - 2, 1);
Expand All @@ -88,12 +90,13 @@ const App = React.createClass({
key: this.index++,
});
this.setState({ items });
},
removeTwo() {
}
removeTwo = () => {
const items = this.state.items;
items.splice(1, 1);
this.setState({ items });
},
}

render() {
return (
<div>
Expand All @@ -110,7 +113,7 @@ const App = React.createClass({
</QueueAnim>
</div>
);
},
});
}
}

ReactDom.render(<App />, document.getElementById('__react-content'));
18 changes: 9 additions & 9 deletions examples/empty-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import QueueAnim from 'rc-queue-anim';
import React from 'react';
import ReactDom from 'react-dom';

const QueueItem = React.createClass({
class QueueItem extends React.Component {
render() {
return (
<QueueAnim>
Expand All @@ -12,18 +12,18 @@ const QueueItem = React.createClass({
<div key="3">Item</div>
</QueueAnim>
);
},
});
}
}

const Item = React.createClass({
class Item extends React.Component {
render() {
return (
<div>Item</div>
);
},
});
}
}

const Page1 = React.createClass({
class Page1 extends React.Component {
render() {
return (
<div>
Expand All @@ -42,7 +42,7 @@ const Page1 = React.createClass({
</QueueAnim>
</div>
);
},
});
}
}

ReactDom.render(<Page1 />, document.getElementById('__react-content'));
19 changes: 11 additions & 8 deletions examples/enter-leave.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import QueueAnim from 'rc-queue-anim';
import React from 'react';
import ReactDom from 'react-dom';

const App = React.createClass({
getInitialState() {
return {
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
items: [{
children: '依次进入1',
key: 1,
Expand All @@ -26,12 +27,14 @@ const App = React.createClass({
key: 6,
}],
};
},
removeAll() {
}

removeAll = () => {
this.setState({
items: [],
});
},
}

render() {
return (
<div>
Expand All @@ -46,7 +49,7 @@ const App = React.createClass({
<button onClick={this.removeAll}>移出所有</button>
</div>
);
},
});
}
}

ReactDom.render(<App />, document.getElementById('__react-content'));
23 changes: 13 additions & 10 deletions examples/monkey-click.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import QueueAnim from 'rc-queue-anim';
import React from 'react';
import ReactDom from 'react-dom';

const App = React.createClass({
getInitialState() {
return {
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
show: true,
items: [{
children: '依次进入1',
Expand All @@ -27,25 +28,27 @@ const App = React.createClass({
key: 6,
}],
};
},
toggle() {
}

toggle = () => {
this.setState({
show: !this.state.show,
});
},
}

render() {
return (
<div>
<button onClick={this.toggle}>切换</button>
<span>{this.state.show ? '显示' : '隐藏'}</span>
<QueueAnim leaveReverse>
{this.state.show ? this.state.items.map((item) => <div key={item.key}>
{item.children}
</div>) : null}
{item.children}
</div>) : null}
</QueueAnim>
</div>
);
},
});
}
}

ReactDom.render(<App />, document.getElementById('__react-content'));
Loading

0 comments on commit 3fb3ead

Please sign in to comment.