OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt |
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt |
6 Code distributed by Google as part of the polymer project is also | 6 Code distributed by Google as part of the polymer project is also |
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt |
8 --> | 8 --> |
9 | 9 |
10 <!-- | 10 <!-- |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 @group Paper Elements | 46 @group Paper Elements |
47 @element paper-progress | 47 @element paper-progress |
48 @extends core-range | 48 @extends core-range |
49 @homepage github.io | 49 @homepage github.io |
50 --> | 50 --> |
51 | 51 |
52 <link rel="import" href="../core-range/core-range.html"> | 52 <link rel="import" href="../core-range/core-range.html"> |
53 | 53 |
54 <polymer-element name="paper-progress" extends="core-range" attributes="secondar
yProgress"> | 54 <polymer-element name="paper-progress" extends="core-range" attributes="secondar
yProgress indeterminate"> |
55 | 55 |
56 <template> | 56 <template> |
57 | 57 |
58 <link rel="stylesheet" href="paper-progress.css"> | 58 <link rel="stylesheet" href="paper-progress.css"> |
59 | 59 |
60 <div id="progressContainer" role="progressbar" aria-valuenow="{{value}}" ari
a-valuemin="{{min}}" aria-valuemax="{{max}}"> | 60 <div id="progressContainer" role="progressbar" aria-valuenow="{{value}}" ari
a-valuemin="{{min}}" aria-valuemax="{{max}}"> |
61 | 61 |
62 <div id="secondaryProgress" _style="width: {{secondaryRatio}}%;"></div> | 62 <div id="secondaryProgress" fit></div> |
63 <div id="activeProgress" _style="width: {{ratio}}%;"></div> | 63 <div id="activeProgress" fit></div> |
64 | 64 |
65 </div> | 65 </div> |
66 | 66 |
67 </template> | 67 </template> |
68 | 68 |
69 <script> | 69 <script> |
70 | 70 |
71 Polymer('paper-progress', { | 71 Polymer('paper-progress', { |
72 | 72 |
73 /** | 73 /** |
74 * The number that represents the current secondary progress. | 74 * The number that represents the current secondary progress. |
75 * | 75 * |
76 * @attribute secondaryProgress | 76 * @attribute secondaryProgress |
77 * @type number | 77 * @type number |
78 * @default 0 | 78 * @default 0 |
79 */ | 79 */ |
80 secondaryProgress: 0, | 80 secondaryProgress: 0, |
81 | 81 |
| 82 /** |
| 83 * Use an indeterminate progress indicator. |
| 84 * |
| 85 * @attribute indeterminate |
| 86 * @type boolean |
| 87 * @default false |
| 88 */ |
| 89 indeterminate: false, |
| 90 |
82 step: 0, | 91 step: 0, |
83 | 92 |
84 observe: { | 93 observe: { |
85 'value secondaryProgress min max': 'update' | 94 'value secondaryProgress min max indeterminate': 'update' |
86 }, | 95 }, |
87 | 96 |
88 update: function() { | 97 update: function() { |
89 this.super(); | 98 this.super(); |
90 this.secondaryProgress = this.clampValue(this.secondaryProgress); | 99 this.secondaryProgress = this.clampValue(this.secondaryProgress); |
91 this.secondaryRatio = this.calcRatio(this.secondaryProgress) * 100; | 100 this.secondaryRatio = this.calcRatio(this.secondaryProgress) * 100; |
| 101 |
| 102 // If we use attribute/class binding, the animation sometimes doesn't tr
anslate properly |
| 103 // on Safari 7.1. So instead, we toggle the class here in the update met
hod. |
| 104 this.$.activeProgress.classList.toggle('indeterminate', this.indetermina
te); |
| 105 }, |
| 106 |
| 107 transformProgress: function(progress, ratio) { |
| 108 var transform = 'scaleX(' + (ratio / 100) + ')'; |
| 109 progress.style.transform = progress.style.webkitTransform = transform; |
| 110 }, |
| 111 |
| 112 ratioChanged: function() { |
| 113 this.transformProgress(this.$.activeProgress, this.ratio); |
| 114 }, |
| 115 |
| 116 secondaryRatioChanged: function() { |
| 117 this.transformProgress(this.$.secondaryProgress, this.secondaryRatio); |
92 } | 118 } |
93 | 119 |
94 }); | 120 }); |
95 | 121 |
96 </script> | 122 </script> |
97 | 123 |
98 </polymer-element> | 124 </polymer-element> |
OLD | NEW |