Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <polymer-element name="viewer-progress-bar" attributes="progress text"> | |
| 2 <template> | |
| 3 <link rel="stylesheet" href="viewer-progress-bar.css"> | |
| 4 <div class="scaler"> | |
| 5 <ul id="segments"></ul> | |
| 6 <div class="center-circle"></div> | |
| 7 </div> | |
| 8 <div id="text">{{text}}</div> | |
| 9 </template> | |
| 10 <script> | |
| 11 Polymer('viewer-progress-bar', { | |
| 12 progress: 0, | |
| 13 text: 'Loading', | |
| 14 segments: [], | |
| 15 ready: function() { | |
| 16 var NUM_SEGMENTS = 8; | |
|
ganetsky1
2014/02/05 16:55:20
You could make this component more resuable and co
raymes
2014/02/07 00:33:41
I had a try at doing this but the math to do the s
raymes
2014/02/10 01:47:45
I ended up changing this to be generic. Done!
| |
| 17 for (var i = 0; i < NUM_SEGMENTS; ++i) { | |
| 18 var segment = document.createElement('li'); | |
| 19 segment.classList.add('segment'); | |
| 20 this.$.segments.appendChild(segment); | |
|
ganetsky1
2014/02/05 16:55:20
It would be better if you just cloned a DOM nome i
raymes
2014/02/07 00:33:41
I tried to do the templating but it didn't work fo
| |
| 21 this.segments.push(segment); | |
| 22 } | |
| 23 this.progressChanged(); | |
| 24 }, | |
| 25 progressChanged: function() { | |
| 26 var numVisible = this.progress * this.segments.length / 100.0; | |
| 27 for (var i = 0; i < this.segments.length; i++) { | |
| 28 this.segments[i].style.visibility = | |
| 29 i < numVisible ? 'visible' : 'hidden'; | |
| 30 } | |
| 31 | |
| 32 if (this.progress == 100) | |
| 33 this.style.opacity = 0; | |
| 34 }, | |
| 35 }); | |
| 36 </script> | |
| 37 </polymer-element> | |
| OLD | NEW |