-
Notifications
You must be signed in to change notification settings - Fork 2
/
fluid-vids.html
executable file
·48 lines (44 loc) · 1.04 KB
/
fluid-vids.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!--
<fluid-vids> v1.0.0 | (c) 2014 @toddmotto | https://github.com/toddmotto/fluidvids-polymer
-->
<polymer-element name="fluid-vids" attributes="src width height">
<template>
<style>
:host {
display: block;
width: 100%;
max-width: 100%;
position: relative;
}
:host iframe {
vertical-align: bottom;
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
}
</style>
<iframe src="{{ src }}" width="{{ width }}" height="{{ height }}" frameborder="0"></iframe>
</template>
<script>
(function () {
function fluidvids () {
var getRatio = function (height, width) {
return ((parseInt(height, 10) / parseInt(width, 10)) * 100) + '%';
};
this.style.paddingTop = getRatio(this.height, this.width);
}
Polymer('fluid-vids', {
publish: {
src: null,
width: 320,
height: 180,
},
ready: function () {
fluidvids.call(this);
}
});
})();
</script>
</polymer-element>