Last active
August 28, 2015 13:24
-
-
Save steelydylan/c1891404f5cf88cb8ab0 to your computer and use it in GitHub Desktop.
youtubeIdからyoutubeを表示するカスタムエレメント(レスポンシブ)
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
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
こんな感じで呼び出せます
<youtube-element youtube-id="D8_iafVEIZU"></youtube-element>