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 66 width : 200px ;
77 display : inline-block ;
88 }
9+
10+ video {
11+ height : 200px ;
12+ width : 200px ;
13+ vertical-align : middle ;
14+ background-color : black ;
15+ }
916}
Original file line number Diff line number Diff line change 11var React = require ( 'react' ) ;
22
33module . exports = React . createClass ( {
4+ getInitialState : function ( ) {
5+ return {
6+ hovering : false
7+ }
8+ } ,
49 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 ( ) }
716 </ div >
817 } ,
918 image : function ( ) {
1019 var link = 'http://i.imgur.com/' + this . props . id + 'h.jpg' ;
1120
1221 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 } ) ;
1335 }
1436} ) ;
You can’t perform that action at this time.
0 commit comments