File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 49
49
/* Carousel-like transition */
50
50
51
51
.carousel-swap-leave {
52
- transition : transform .3 s ease-in-out;
52
+ transition : transform 2 s ease-in-out;
53
53
transform : translate (0 , 0 );
54
54
}
55
55
.carousel-swap-leave-active {
56
56
transform : translate (-100% , 0 );
57
57
}
58
58
59
59
.carousel-swap-enter {
60
- transition : transform .3 s ease-in-out;
60
+ transition : transform 2 s ease-in-out;
61
61
transform : translate (100% , 0 );
62
62
}
63
63
.carousel-swap-enter-active {
64
64
transform : translate (0 , 0 );
65
65
}
66
66
67
67
.carousel-swap-height {
68
- transition : height .3 s ease-in-out;
68
+ transition : height 2 s ease-in-out;
69
69
}
70
70
71
71
Original file line number Diff line number Diff line change @@ -4,10 +4,11 @@ import ReactCSSTransitionReplace from '../../src/ReactCSSTransitionReplace.jsx'
4
4
5
5
class ContentSwapper extends React . Component {
6
6
7
- state = { swapped : false }
7
+ state = { index : 0 }
8
8
9
9
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 } )
11
12
}
12
13
13
14
render ( ) {
@@ -18,7 +19,7 @@ class ContentSwapper extends React.Component {
18
19
19
20
return (
20
21
< ReactCSSTransitionReplace { ...this . props } style = { style } onClick = { this . handleClick } >
21
- { this . state . swapped ? content [ 1 ] : content [ 0 ] }
22
+ { content [ this . state . index ] }
22
23
</ ReactCSSTransitionReplace >
23
24
)
24
25
}
Original file line number Diff line number Diff line change @@ -71,10 +71,11 @@ class Demo extends React.Component {
71
71
< code > { '<ReactCSSTransitionReplace transitionName="carousel-swap" /*...*/ style={{width: 600}}>' } </ code > .
72
72
</ p >
73
73
74
- < ContentSwapper transitionName = "carousel-swap" transitionEnterTimeout = { 500 } transitionLeaveTimeout = { 500 }
74
+ < ContentSwapper transitionName = "carousel-swap" transitionEnterTimeout = { 2000 } transitionLeaveTimeout = { 2000 }
75
75
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" />
78
79
</ ContentSwapper >
79
80
80
81
< h3 id = "roll-up" > Add/Remove Content</ h3 >
You can’t perform that action at this time.
0 commit comments