OLD | NEW |
---|---|
(Empty) | |
1 <polymer-element name="viewer-button" attributes="src latchable"> | |
2 <template> | |
3 <link rel="stylesheet" href="viewer-button.css"> | |
4 <div id="icon"></div> | |
5 </template> | |
6 <script> | |
7 (function() { | |
8 var dpi = ''; | |
9 | |
10 Polymer('viewer-button', { | |
11 src: '', | |
12 latchable: false, | |
13 srcChanged: function() { | |
ganetsky1
2013/12/18 20:05:05
fyi you can use oldValue, newValue as arguments he
| |
14 if (this.src) { | |
15 if (!dpi) { | |
16 var mql = window.matchMedia('(-webkit-min-device-pixel-ratio: 1.3'); | |
17 dpi = mql.matches ? 'hi' : 'low'; | |
18 } | |
19 this.$.icon.style.backgroundImage = | |
20 'url(elements/viewer-button/img/' + dpi + 'DPI/' + this.src + ')'; | |
21 } | |
ganetsky1
2013/12/18 20:05:05
You probably want an else branch which unsets this
raymes
2013/12/18 23:28:54
Done.
| |
22 }, | |
23 latchableChanged: function() { | |
ganetsky1
2013/12/18 20:05:05
fyi, you can use oldValue, newValue as arguments h
| |
24 if (this.latchable) | |
25 this.classList.add('latchable') | |
26 else | |
27 this.classList.remove('latchable') | |
28 }, | |
29 }); | |
30 })(); | |
31 </script> | |
32 </polymer-element> | |
OLD | NEW |