@@ -3,39 +3,68 @@ import { Navbar, NavBrand, Nav, NavItem, Grid } from 'react-bootstrap';
3
3
4
4
import ContentSwapper from './ContentSwapper.jsx' ;
5
5
6
+ import ContentLong from './ContentLong.jsx' ;
7
+ import ContentShort from './ContentShort.jsx' ;
6
8
7
- function Demo ( ) {
8
- const transitionProps = {
9
- transitionEnterTimeout : 500 ,
10
- transitionLeaveTimeout : 300 ,
11
- transitionHeight : false
12
- } ;
13
-
14
- return (
15
- < div >
16
- < Navbar >
17
- < NavBrand > ReactCSSTransitionReplace</ NavBrand >
18
- < Nav right >
19
- < NavItem href = "https://github.com/marnusw/react-css-transition-replace" target = "_blank" > GitHub</ NavItem >
20
- </ Nav >
21
- </ Navbar >
22
-
23
- < Grid >
24
- < br />
25
- < p className = "text-danger" > < em > Click any content to trigger the transition.</ em > </ p >
26
-
27
- < h2 > Cross-fade transition</ h2 >
28
- < ContentSwapper { ...transitionProps } transitionName = "cross-fade" />
29
-
30
- < h2 > Fade out, then fade in transition</ h2 >
31
- < ContentSwapper { ...transitionProps } transitionName = "wait-fade" />
32
-
33
- < h2 > Carousel-like transition</ h2 >
34
- < ContentSwapper { ...transitionProps } transitionName = "carousel" />
35
-
36
- </ Grid >
37
- </ div >
38
- ) ;
9
+ class Demo extends React . Component {
10
+
11
+ componentDidMount ( ) {
12
+ [
13
+ '/img/vista1.jpg' ,
14
+ '/img/vista2.jpg' ,
15
+ '/img/vista3.jpg' ,
16
+ '/img/vista4.jpg'
17
+ ] . forEach ( src => {
18
+ const img = new window . Image ( ) ;
19
+ img . src = src ;
20
+ } ) ;
21
+ }
22
+
23
+ render ( ) {
24
+ const transitionProps = {
25
+ transitionEnterTimeout : 500 ,
26
+ transitionLeaveTimeout : 300 ,
27
+ transitionHeight : false
28
+ } ;
29
+
30
+ return (
31
+ < div >
32
+ < Navbar >
33
+ < NavBrand > ReactCSSTransitionReplace</ NavBrand >
34
+ < Nav right >
35
+ < NavItem href = "https://github.com/marnusw/react-css-transition-replace" target = "_blank" > GitHub</ NavItem >
36
+ </ Nav >
37
+ </ Navbar >
38
+
39
+ < Grid >
40
+ < br />
41
+ < p className = "text-danger" > < em > Click any content to trigger the transition.</ em > </ p >
42
+
43
+ < h2 > Cross-fade transition</ h2 >
44
+ < ContentSwapper { ...transitionProps } transitionName = "cross-fade" >
45
+ < img key = "img1" src = "/img/vista1.jpg" />
46
+ < img key = "img2" src = "/img/vista2.jpg" />
47
+ </ ContentSwapper >
48
+
49
+ < h2 > Fade out, then fade in transition</ h2 >
50
+ < ContentSwapper { ...transitionProps } transitionName = "wait-fade" >
51
+ < ContentShort key = "short" />
52
+ < ContentLong key = "long" />
53
+ </ ContentSwapper >
54
+
55
+ < h2 > Carousel-like transition</ h2 >
56
+
57
+ < div style = { { width : 600 } } >
58
+ < ContentSwapper { ...transitionProps } transitionName = "carousel-swap" className = "carousel" >
59
+ < img key = "img3" src = "/img/vista3.jpg" />
60
+ < img key = "img4" src = "/img/vista4.jpg" />
61
+ </ ContentSwapper >
62
+ </ div >
63
+
64
+ </ Grid >
65
+ </ div >
66
+ ) ;
67
+ }
39
68
}
40
69
41
70
export default Demo ;
0 commit comments