Skip to content

Commit

Permalink
Flux - 24 - Playing Videos on Mouseover
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Jul 5, 2015
1 parent 56668a1 commit 54c0f79
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
7 changes: 7 additions & 0 deletions imgur-client/sass/image-preview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@
width: 200px;
display: inline-block;
}

video {
height: 200px;
width: 200px;
vertical-align: middle;
background-color: black;
}
}
26 changes: 24 additions & 2 deletions imgur-client/src/components/image-preview.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
var React = require('react');

module.exports = React.createClass({
getInitialState: function() {
return {
hovering: false
}
},
render: function() {
return <div className="image-preview">
{this.image()}
return <div
className="image-preview"
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
>
{this.props.animated && this.state.hovering ? this.video() : this.image()}
</div>
},
image: function() {
var link = 'http://i.imgur.com/' + this.props.id + 'h.jpg';

return <img src={link} />
},
video: function() {
return <div>
<video preload='auto' autoPlay='autoplay' loop='loop' webkit-playsinline>
<source src={this.props.mp4} type='video/mp4'></source>
</video>
</div>
},
handleMouseEnter: function() {
this.setState({hovering: true});
},
handleMouseLeave: function() {
this.setState({hovering: false});
}
});

0 comments on commit 54c0f79

Please sign in to comment.