Blame view

bower_components/paper-progress/paper-progress.html 10.1 KB
73bcce88   luigser   COMPONENTS
1
2
3
4
5
6
7
8
9
10
11
  <!--
  @license
  Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
  This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
  The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
  The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
  Code distributed by Google as part of the polymer project is also
  subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
  -->
  
  <link rel="import" href="../polymer/polymer.html">
73bcce88   luigser   COMPONENTS
12
  <link rel="import" href="../iron-range-behavior/iron-range-behavior.html">
dbc787cf   Luigi Serra   Controllet cross ...
13
  <link rel="import" href="../paper-styles/color.html">
c5169e0e   Renato De Donato   a new hope
14
  <link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
73bcce88   luigser   COMPONENTS
15
16
  
  <!--
73bcce88   luigser   COMPONENTS
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  The progress bars are for situations where the percentage completed can be
  determined. They give users a quick sense of how much longer an operation
  will take.
  
  Example:
  
      <paper-progress value="10"></paper-progress>
  
  There is also a secondary progress which is useful for displaying intermediate
  progress, such as the buffer level during a streaming playback progress bar.
  
  Example:
  
      <paper-progress value="10" secondary-progress="30"></paper-progress>
  
  ### Styling progress bar:
  
  To change the active progress bar color:
  
      paper-progress {
         --paper-progress-active-color: #e91e63;
      }
  
  To change the secondary progress bar color:
  
      paper-progress {
        --paper-progress-secondary-color: #f8bbd0;
      }
  
  To change the progress bar background color:
  
      paper-progress {
        --paper-progress-container-color: #64ffda;
      }
  
  Add the class `transiting` to a paper-progress to animate the progress bar when
  the value changed. You can also customize the transition:
  
      paper-progress {
        --paper-progress-transition-duration: 0.08s;
        --paper-progress-transition-timing-function: ease;
        --paper-progress-transition-transition-delay: 0s;
      }
e619a3b0   Luigi Serra   Controllet cross ...
60
61
62
  
  The following mixins are available for styling:
  
c5169e0e   Renato De Donato   a new hope
63
64
65
66
67
68
69
70
71
72
73
  Custom property                             | Description                                 | Default
  --------------------------------------------|---------------------------------------------|----------
  --paper-progress-container-color            | Mixin applied to container                  | --google-grey-300
  --paper-progress-transition-duration        | Duration of the transition                  | 0.008s
  --paper-progress-transition-timing-function | The timing function for the transition      | ease
  --paper-progress-transition-delay           | delay for the transition                    | 0s
  --paper-progress-active-color               | The color of the active bar                 | --google-green-500
  --paper-progress-secondary-color            | The color of the secondary bar              | --google-green-100
  --paper-progress-disabled-active-color      | The color of the active bar if disabled     | --google-grey-500
  --paper-progress-disabled-secondary-color   | The color of the secondary bar if disabled  | --google-grey-300
  --paper-progress-height                     | The height of the progress bar              | 4px
e619a3b0   Luigi Serra   Controllet cross ...
74
  
73bcce88   luigser   COMPONENTS
75
76
77
78
79
80
81
  @group Paper Elements
  @element paper-progress
  @hero hero.svg
  @demo demo/index.html
  -->
  
  <dom-module id="paper-progress">
c5169e0e   Renato De Donato   a new hope
82
83
84
85
86
87
88
    <style>
      :host {
        display: block;
        width: 200px;
        position: relative;
        overflow: hidden;
      }
e619a3b0   Luigi Serra   Controllet cross ...
89
  
c5169e0e   Renato De Donato   a new hope
90
91
92
      #progressContainer {
        position: relative;
      }
e619a3b0   Luigi Serra   Controllet cross ...
93
  
c5169e0e   Renato De Donato   a new hope
94
95
96
97
98
      #progressContainer,
      /* the stripe for the indeterminate animation*/
      .indeterminate:after {
        height: var(--paper-progress-height, 4px);
      }
e619a3b0   Luigi Serra   Controllet cross ...
99
  
c5169e0e   Renato De Donato   a new hope
100
101
102
103
104
      #primaryProgress,
      #secondaryProgress,
      .indeterminate:after {
        @apply(--layout-fit);
      }
73bcce88   luigser   COMPONENTS
105
  
c5169e0e   Renato De Donato   a new hope
106
107
108
109
      #progressContainer,
      .indeterminate:after {
        background-color: var(--paper-progress-container-color, --google-grey-300);
      }
73bcce88   luigser   COMPONENTS
110
  
c5169e0e   Renato De Donato   a new hope
111
112
113
114
      :host(.transiting) #primaryProgress,
      :host(.transiting) #secondaryProgress {
        -webkit-transition-property: -webkit-transform;
        transition-property: transform;
73bcce88   luigser   COMPONENTS
115
  
c5169e0e   Renato De Donato   a new hope
116
117
118
        /* Duration */
        -webkit-transition-duration: var(--paper-progress-transition-duration, 0.08s);
        transition-duration: var(--paper-progress-transition-duration, 0.08s);
73bcce88   luigser   COMPONENTS
119
  
c5169e0e   Renato De Donato   a new hope
120
121
122
        /* Timing function */
        -webkit-transition-timing-function: var(--paper-progress-transition-timing-function, ease);
        transition-timing-function: var(--paper-progress-transition-timing-function, ease);
73bcce88   luigser   COMPONENTS
123
  
c5169e0e   Renato De Donato   a new hope
124
125
126
127
        /* Delay */
        -webkit-transition-delay: var(--paper-progress-transition-delay, 0s);
        transition-delay: var(--paper-progress-transition-delay, 0s);
      }
73bcce88   luigser   COMPONENTS
128
  
c5169e0e   Renato De Donato   a new hope
129
130
131
132
133
134
135
136
137
      #primaryProgress,
      #secondaryProgress {
        @apply(--layout-fit);
        -webkit-transform-origin: left center;
        transform-origin: left center;
        -webkit-transform: scaleX(0);
        transform: scaleX(0);
        will-change: transform;
      }
73bcce88   luigser   COMPONENTS
138
  
c5169e0e   Renato De Donato   a new hope
139
140
141
      #primaryProgress {
        background-color: var(--paper-progress-active-color, --google-green-500);
      }
73bcce88   luigser   COMPONENTS
142
  
c5169e0e   Renato De Donato   a new hope
143
144
145
146
      #secondaryProgress {
        position: relative;
        background-color: var(--paper-progress-secondary-color, --google-green-100);
      }
e619a3b0   Luigi Serra   Controllet cross ...
147
  
c5169e0e   Renato De Donato   a new hope
148
149
150
      :host([disabled]) #primaryProgress {
        background-color: var(--paper-progress-disabled-active-color, --google-grey-500);
      }
e619a3b0   Luigi Serra   Controllet cross ...
151
  
c5169e0e   Renato De Donato   a new hope
152
153
154
      :host([disabled]) #secondaryProgress {
        background-color: var(--paper-progress-disabled-active-color, --google-grey-300);
      }
e619a3b0   Luigi Serra   Controllet cross ...
155
  
c5169e0e   Renato De Donato   a new hope
156
157
158
159
160
161
      :host(:not([disabled])) #primaryProgress.indeterminate {
        -webkit-transform-origin: right center;
        transform-origin: right center;
        -webkit-animation: indeterminate-bar 2s linear infinite;
        animation: indeterminate-bar 2s linear infinite;
      }
e619a3b0   Luigi Serra   Controllet cross ...
162
  
c5169e0e   Renato De Donato   a new hope
163
164
165
166
      :host(:not([disabled])) #primaryProgress.indeterminate:after {
        content: "";
        -webkit-transform-origin: center center;
        transform-origin: center center;
73bcce88   luigser   COMPONENTS
167
  
c5169e0e   Renato De Donato   a new hope
168
169
170
        -webkit-animation: indeterminate-splitter 2s linear infinite;
        animation: indeterminate-splitter 2s linear infinite;
      }
e619a3b0   Luigi Serra   Controllet cross ...
171
  
c5169e0e   Renato De Donato   a new hope
172
173
174
      @-webkit-keyframes indeterminate-bar {
        0% {
          -webkit-transform: scaleX(1) translateX(-100%);
e619a3b0   Luigi Serra   Controllet cross ...
175
        }
c5169e0e   Renato De Donato   a new hope
176
177
178
179
180
181
182
183
184
        50% {
          -webkit-transform: scaleX(1) translateX(0%);
        }
        75% {
          -webkit-transform: scaleX(1) translateX(0%);
          -webkit-animation-timing-function: cubic-bezier(.28,.62,.37,.91);
        }
        100% {
          -webkit-transform: scaleX(0) translateX(0%);
e619a3b0   Luigi Serra   Controllet cross ...
185
        }
c5169e0e   Renato De Donato   a new hope
186
      }
e619a3b0   Luigi Serra   Controllet cross ...
187
  
c5169e0e   Renato De Donato   a new hope
188
189
190
191
192
193
194
195
196
197
      @-webkit-keyframes indeterminate-splitter {
        0% {
          -webkit-transform: scaleX(.75) translateX(-125%);
        }
        30% {
          -webkit-transform: scaleX(.75) translateX(-125%);
          -webkit-animation-timing-function: cubic-bezier(.42,0,.6,.8);
        }
        90% {
          -webkit-transform: scaleX(.75) translateX(125%);
e619a3b0   Luigi Serra   Controllet cross ...
198
        }
c5169e0e   Renato De Donato   a new hope
199
200
201
202
        100% {
          -webkit-transform: scaleX(.75) translateX(125%);
        }
      }
a1a3bc73   Luigi Serra   graphs updates
203
  
c5169e0e   Renato De Donato   a new hope
204
205
206
207
208
209
      @keyframes indeterminate-bar {
        0% {
          transform: scaleX(1) translateX(-100%);
        }
        50% {
          transform: scaleX(1) translateX(0%);
73bcce88   luigser   COMPONENTS
210
        }
c5169e0e   Renato De Donato   a new hope
211
212
213
214
215
216
217
218
        75% {
          transform: scaleX(1) translateX(0%);
          animation-timing-function: cubic-bezier(.28,.62,.37,.91);
        }
        100% {
          transform: scaleX(0) translateX(0%);
        }
      }
a1a3bc73   Luigi Serra   graphs updates
219
  
c5169e0e   Renato De Donato   a new hope
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
      @keyframes indeterminate-splitter {
        0% {
          transform: scaleX(.75) translateX(-125%);
        }
        30% {
          transform: scaleX(.75) translateX(-125%);
          animation-timing-function: cubic-bezier(.42,0,.6,.8);
        }
        90% {
          transform: scaleX(.75) translateX(125%);
        }
        100% {
          transform: scaleX(.75) translateX(125%);
        }
      }
    </style>
    <template>
e619a3b0   Luigi Serra   Controllet cross ...
237
238
239
      <div id="progressContainer">
        <div id="secondaryProgress" hidden$="[[_hideSecondaryProgress(secondaryRatio)]]"></div>
        <div id="primaryProgress"></div>
73bcce88   luigser   COMPONENTS
240
241
242
243
244
245
      </div>
    </template>
  </dom-module>
  
  <script>
    Polymer({
c5169e0e   Renato De Donato   a new hope
246
  
73bcce88   luigser   COMPONENTS
247
248
249
250
251
252
253
      is: 'paper-progress',
  
      behaviors: [
        Polymer.IronRangeBehavior
      ],
  
      properties: {
c5169e0e   Renato De Donato   a new hope
254
  
73bcce88   luigser   COMPONENTS
255
256
257
258
259
        /**
         * The number that represents the current secondary progress.
         */
        secondaryProgress: {
          type: Number,
e619a3b0   Luigi Serra   Controllet cross ...
260
          value: 0
73bcce88   luigser   COMPONENTS
261
262
263
264
265
266
267
268
        },
  
        /**
         * The secondary ratio
         */
        secondaryRatio: {
          type: Number,
          value: 0,
e619a3b0   Luigi Serra   Controllet cross ...
269
          readOnly: true
73bcce88   luigser   COMPONENTS
270
271
272
273
274
275
276
277
        },
  
        /**
         * Use an indeterminate progress indicator.
         */
        indeterminate: {
          type: Boolean,
          value: false,
73bcce88   luigser   COMPONENTS
278
          observer: '_toggleIndeterminate'
e619a3b0   Luigi Serra   Controllet cross ...
279
280
281
282
283
284
285
286
287
288
        },
  
        /**
         * True if the progress is disabled.
         */
        disabled: {
          type: Boolean,
          value: false,
          reflectToAttribute: true,
          observer: '_disabledChanged'
73bcce88   luigser   COMPONENTS
289
290
291
292
        }
      },
  
      observers: [
e619a3b0   Luigi Serra   Controllet cross ...
293
        '_progressChanged(secondaryProgress, value, min, max)'
73bcce88   luigser   COMPONENTS
294
295
      ],
  
e619a3b0   Luigi Serra   Controllet cross ...
296
297
298
299
300
      hostAttributes: {
        role: 'progressbar'
      },
  
      _toggleIndeterminate: function(indeterminate) {
73bcce88   luigser   COMPONENTS
301
302
        // If we use attribute/class binding, the animation sometimes doesn't translate properly
        // on Safari 7.1. So instead, we toggle the class here in the update method.
e619a3b0   Luigi Serra   Controllet cross ...
303
        this.toggleClass('indeterminate', indeterminate, this.$.primaryProgress);
73bcce88   luigser   COMPONENTS
304
305
306
307
308
309
310
      },
  
      _transformProgress: function(progress, ratio) {
        var transform = 'scaleX(' + (ratio / 100) + ')';
        progress.style.transform = progress.style.webkitTransform = transform;
      },
  
e619a3b0   Luigi Serra   Controllet cross ...
311
312
      _mainRatioChanged: function(ratio) {
        this._transformProgress(this.$.primaryProgress, ratio);
73bcce88   luigser   COMPONENTS
313
314
      },
  
e619a3b0   Luigi Serra   Controllet cross ...
315
316
317
318
319
320
321
322
      _progressChanged: function(secondaryProgress, value, min, max) {
        secondaryProgress = this._clampValue(secondaryProgress);
        value = this._clampValue(value);
  
        var secondaryRatio = this._calcRatio(secondaryProgress) * 100;
        var mainRatio = this._calcRatio(value) * 100;
  
        this._setSecondaryRatio(secondaryRatio);
73bcce88   luigser   COMPONENTS
323
        this._transformProgress(this.$.secondaryProgress, secondaryRatio);
e619a3b0   Luigi Serra   Controllet cross ...
324
325
326
327
328
329
330
331
332
333
334
        this._transformProgress(this.$.primaryProgress, mainRatio);
  
        this.secondaryProgress = secondaryProgress;
  
        this.setAttribute('aria-valuenow', value);
        this.setAttribute('aria-valuemin', min);
        this.setAttribute('aria-valuemax', max);
      },
  
      _disabledChanged: function(disabled) {
        this.setAttribute('aria-disabled', disabled ? 'true' : 'false');
73bcce88   luigser   COMPONENTS
335
336
      },
  
e619a3b0   Luigi Serra   Controllet cross ...
337
338
      _hideSecondaryProgress: function(secondaryRatio) {
        return secondaryRatio === 0;
73bcce88   luigser   COMPONENTS
339
      }
c5169e0e   Renato De Donato   a new hope
340
  
73bcce88   luigser   COMPONENTS
341
    });
c5169e0e   Renato De Donato   a new hope
342
  
73bcce88   luigser   COMPONENTS
343
  </script>