3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
11 <link rel=
"import" href=
"../polymer/polymer.html">
12 <link rel=
"import" href=
"../paper-styles/paper-styles.html">
13 <link rel=
"import" href=
"../iron-range-behavior/iron-range-behavior.html">
14 <link rel=
"import" href=
"../iron-flex-layout/classes/iron-flex-layout.html">
17 The progress bars are for situations where the percentage completed can be
18 determined. They give users a quick sense of how much longer an operation
23 <paper-progress value="10"></paper-progress>
25 There is also a secondary progress which is useful for displaying intermediate
26 progress, such as the buffer level during a streaming playback progress bar.
30 <paper-progress value="10" secondary-progress="30"></paper-progress>
32 ### Styling progress bar:
34 To change the active progress bar color:
37 --paper-progress-active-color: #e91e63;
40 To change the secondary progress bar color:
43 --paper-progress-secondary-color: #f8bbd0;
46 To change the progress bar background color:
49 --paper-progress-container-color: #64ffda;
52 Add the class `transiting` to a paper-progress to animate the progress bar when
53 the value changed. You can also customize the transition:
56 --paper-progress-transition-duration: 0.08s;
57 --paper-progress-transition-timing-function: ease;
58 --paper-progress-transition-transition-delay: 0s;
62 @element paper-progress
67 <dom-module id=
"paper-progress">
70 display: inline-block;
75 :host(.transiting) #activeProgress,
76 :host(.transiting) #secondaryProgress {
77 -webkit-transition-property: -webkit-transform;
78 transition-property: transform;
81 -webkit-transition-duration: var(--paper-progress-transition-duration,
0.08s);
82 transition-duration: var(--paper-progress-transition-duration,
0.08s);
85 -webkit-transition-timing-function: var(--paper-progress-transition-timing-function, ease);
86 transition-timing-function: var(--paper-progress-transition-timing-function, ease);
89 -webkit-transition-delay: var(--paper-progress-transition-delay,
0s);
90 transition-delay: var(--paper-progress-transition-delay,
0s);
96 background-color: var(--paper-progress-container-color, --google-grey-
300);
102 -webkit-transform-origin: left center;
103 transform-origin: left center;
104 -webkit-transform: scaleX(
0);
105 transform: scaleX(
0);
109 background-color: var(--paper-progress-active-color, --google-green-
500);
113 background-color: var(--paper-progress-secondary-color, --google-green-
100);
116 #activeProgress.indeterminate {
117 -webkit-transform-origin: center center;
118 transform-origin: center center;
119 -webkit-animation: indeterminate-bar
1s linear infinite;
120 animation: indeterminate-bar
1s linear infinite;
123 @-webkit-keyframes indeterminate-bar {
125 -webkit-transform: translate(-
50%) scaleX(
0);
128 -webkit-transform: translate(
0%) scaleX(
0.3);
131 -webkit-transform: translate(
50%) scaleX(
0);
135 @keyframes indeterminate-bar {
137 transform: translate(-
50%) scaleX(
0);
140 transform: translate(
0%) scaleX(
0.3);
143 transform: translate(
50%) scaleX(
0);
148 <div id=
"progressContainer" role=
"progressbar" aria-valuenow$=
"{{value}}" aria-valuemin$=
"{{min}}" aria-valuemax$=
"{{max}}">
149 <div id=
"secondaryProgress" class=
"fit"></div>
150 <div id=
"activeProgress" class=
"fit"></div>
158 is
: 'paper-progress',
161 Polymer
.IronRangeBehavior
167 * The number that represents the current secondary progress.
176 * The secondary ratio
182 observer
: '_secondaryRatioChanged'
186 * Use an indeterminate progress indicator.
192 observer
: '_toggleIndeterminate'
197 '_ratioChanged(ratio)',
198 '_secondaryProgressChanged(secondaryProgress, min, max)'
201 _toggleIndeterminate: function() {
202 // If we use attribute/class binding, the animation sometimes doesn't translate properly
203 // on Safari 7.1. So instead, we toggle the class here in the update method.
204 this.toggleClass('indeterminate', this.indeterminate
, this.$.activeProgress
);
207 _transformProgress: function(progress
, ratio
) {
208 var transform
= 'scaleX(' + (ratio
/ 100) + ')';
209 progress
.style
.transform
= progress
.style
.webkitTransform
= transform
;
212 _ratioChanged: function(ratio
) {
213 this._transformProgress(this.$.activeProgress
, ratio
);
216 _secondaryRatioChanged: function(secondaryRatio
) {
217 this._transformProgress(this.$.secondaryProgress
, secondaryRatio
);
220 _secondaryProgressChanged: function() {
221 this.secondaryProgress
= this._clampValue(this.secondaryProgress
);
222 this._setSecondaryRatio(this._calcRatio(this.secondaryProgress
) * 100);