Skip to content

Instantly share code, notes, and snippets.

@steelydylan
Last active August 28, 2015 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steelydylan/c1891404f5cf88cb8ab0 to your computer and use it in GitHub Desktop.
Save steelydylan/c1891404f5cf88cb8ab0 to your computer and use it in GitHub Desktop.
youtubeIdからyoutubeを表示するカスタムエレメント(レスポンシブ)
<dom-module name="youtube-element" id="youtube-element">
<template>
<style>
.youtube-wrap{
width:100%;
height:0;
padding-bottom:56.25%;
position:relative;
}
.youtube-wrap iframe{
width:100%;
height:100%;
top:0;
left:0;
position:absolute;
}
</style>
<div class="youtube-wrap">
<iframe width="560" height="315" src$="{{youtubeUrl}}" frameborder="0" allowfullscreen></iframe>
</div>
</template>
<script>
Polymer({
is:"youtube-element",
properties:{
youtubeId:String,
youtubeUrl:{
type:String,
computed:'getYoutubeUrl(youtubeId)'
}
},
getYoutubeUrl:function(youtubeId){
return "https://www.youtube.com/embed/"+youtubeId;
}
});
</script>
</dom-module>
@steelydylan
Copy link
Author

こんな感じで呼び出せます
<youtube-element youtube-id="D8_iafVEIZU"></youtube-element>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment