forked from xnf/img-background
-
Notifications
You must be signed in to change notification settings - Fork 0
/
img-background.html
37 lines (35 loc) · 1.05 KB
/
img-background.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
<polymer-element name="img-background" attributes="src class">
<template>
<style>
#web-component-img-background {
position: fixed;
top: 0;
left: 0;
z-index: -1;
min-height: 100%;
min-width: 100%;
}
#web-component-img-background.h {
width: 100%
}
#web-component-img-background.v {
height: 100%
}
</style>
<img src="{{src}}" id="web-component-img-background" class="{{class}}"/>
</template>
<script>
Polymer('img-background', {
ready: function () {
var elm = this;
var updateImage = function () {
elm.class = (window.outerHeight < window.outerWidth) ? 'h' : 'v';
}
window.onresize = function () {
updateImage();
}
updateImage();
}
});
</script>
</polymer-element>