File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 6
6
width : 200px ;
7
7
display : inline-block ;
8
8
}
9
+
10
+ video {
11
+ height : 200px ;
12
+ width : 200px ;
13
+ vertical-align : middle ;
14
+ background-color : black ;
15
+ }
9
16
}
Original file line number Diff line number Diff line change 1
1
var React = require ( 'react' ) ;
2
2
3
3
module . exports = React . createClass ( {
4
+ getInitialState : function ( ) {
5
+ return {
6
+ hovering : false
7
+ }
8
+ } ,
4
9
render : function ( ) {
5
- return < div className = "image-preview" >
6
- { this . image ( ) }
10
+ return < div
11
+ className = "image-preview"
12
+ onMouseEnter = { this . handleMouseEnter }
13
+ onMouseLeave = { this . handleMouseLeave }
14
+ >
15
+ { this . props . animated && this . state . hovering ? this . video ( ) : this . image ( ) }
7
16
</ div >
8
17
} ,
9
18
image : function ( ) {
10
19
var link = 'http://i.imgur.com/' + this . props . id + 'h.jpg' ;
11
20
12
21
return < img src = { link } />
22
+ } ,
23
+ video : function ( ) {
24
+ return < div >
25
+ < video preload = 'auto' autoPlay = 'autoplay' loop = 'loop' webkit-playsinline >
26
+ < source src = { this . props . mp4 } type = 'video/mp4' > </ source >
27
+ </ video >
28
+ </ div >
29
+ } ,
30
+ handleMouseEnter : function ( ) {
31
+ this . setState ( { hovering : true } ) ;
32
+ } ,
33
+ handleMouseLeave : function ( ) {
34
+ this . setState ( { hovering : false } ) ;
13
35
}
14
36
} ) ;
You can’t perform that action at this time.
0 commit comments