Last active
August 29, 2015 14:11
-
-
Save poteto/f50f7adfbe612ddf7c9e to your computer and use it in GitHub Desktop.
lazy-video component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
provider : null, | |
isDisplayed : false, | |
videoTitle : null, | |
videoId : null, | |
classNames : [ 'lazyLoad-container' ], | |
attributeBindings : [ 'style' ], | |
videoThumbnail : null, | |
click: function() { | |
this.set('isDisplayed', true); | |
}, | |
videoSrc: Ember.computed('provider', 'videoId', function() { | |
var providers = this.get('providers'); | |
var provider = this.get('provider'); | |
var videoId = this.get('videoId'); | |
return providers.getUrl(provider, 'embedUrl', videoId, { autoplay: 1 }); | |
}), | |
_getVideoThumbnail: (function() { | |
var providers = this.get('providers'); | |
var provider = this.get('provider'); | |
var videoId = this.get('videoId'); | |
providers.get(provider).thumbnailUrl(videoId).then(function(res) { | |
this.set('videoThumbnail', res); | |
}.bind(this)); | |
}).on('didInsertElement'), | |
style: Ember.computed('videoThumbnail', function() { | |
var thumbnail = this.get('videoThumbnail'); | |
return 'background-image: url(' + thumbnail + ') center center no-repeat'; | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.lazyLoad-container { | |
cursor: pointer; | |
width: 100%; | |
height: 100%; | |
background: black; | |
background-size: cover; | |
background-position: center center; | |
background-repeat: no-repeat; | |
&:hover { | |
.lazyLoad-play SVG { | |
fill: rgb(206, 19, 18); | |
} | |
} | |
} | |
.lazyLoad-play { | |
$width: 85px; | |
$height: 60px; | |
$marginLeft: $width / -2; | |
$marginTop: $height / -2; | |
width: $width; | |
height: $height; | |
margin-left: $marginLeft; | |
margin-top: $marginTop; | |
cursor: pointer; | |
outline: 0; | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
z-index: 1000; | |
svg { | |
height: 100%; | |
width: 100%; | |
fill: rgb(31,31,31); | |
@include opacity(0.9); | |
cursor: pointer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment