Skip to content

Commit 0249594

Browse files
committed
Add third image to the carousel animation.
1 parent ed373e6 commit 0249594

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

demo/assets/transitions.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,23 @@
4949
/* Carousel-like transition */
5050

5151
.carousel-swap-leave {
52-
transition: transform .3s ease-in-out;
52+
transition: transform 2s ease-in-out;
5353
transform: translate(0, 0);
5454
}
5555
.carousel-swap-leave-active {
5656
transform: translate(-100%, 0);
5757
}
5858

5959
.carousel-swap-enter {
60-
transition: transform .3s ease-in-out;
60+
transition: transform 2s ease-in-out;
6161
transform: translate(100%, 0);
6262
}
6363
.carousel-swap-enter-active {
6464
transform: translate(0, 0);
6565
}
6666

6767
.carousel-swap-height {
68-
transition: height .3s ease-in-out;
68+
transition: height 2s ease-in-out;
6969
}
7070

7171

demo/components/ContentSwapper.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import ReactCSSTransitionReplace from '../../src/ReactCSSTransitionReplace.jsx'
44

55
class ContentSwapper extends React.Component {
66

7-
state = {swapped: false}
7+
state = {index: 0}
88

99
handleClick = () => {
10-
this.setState({swapped: !this.state.swapped})
10+
const index = this.state.index + 1
11+
this.setState({index: index >= React.Children.count(this.props.children) ? 0 : index})
1112
}
1213

1314
render() {
@@ -18,7 +19,7 @@ class ContentSwapper extends React.Component {
1819

1920
return (
2021
<ReactCSSTransitionReplace {...this.props} style={style} onClick={this.handleClick}>
21-
{this.state.swapped ? content[1] : content[0]}
22+
{content[this.state.index]}
2223
</ReactCSSTransitionReplace>
2324
)
2425
}

demo/components/Demo.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ class Demo extends React.Component {
7171
<code>{'<ReactCSSTransitionReplace transitionName="carousel-swap" /*...*/ style={{width: 600}}>'}</code>.
7272
</p>
7373

74-
<ContentSwapper transitionName="carousel-swap" transitionEnterTimeout={500} transitionLeaveTimeout={500}
74+
<ContentSwapper transitionName="carousel-swap" transitionEnterTimeout={2000} transitionLeaveTimeout={2000}
7575
style={{width: 600}}>
76-
<img key="img3" src="img/vista3.jpg" width="600" height="255"/>
77-
<img key="img4" src="img/vista4.jpg" width="600" height="280"/>
76+
<img key="img1" src="img/vista3.jpg" width="600" height="255"/>
77+
<img key="img2" src="img/vista4.jpg" width="600" height="280"/>
78+
<img key="img3" src="img/vista2.jpg" width="600" height="290"/>
7879
</ContentSwapper>
7980

8081
<h3 id="roll-up">Add/Remove Content</h3>

0 commit comments

Comments
 (0)