OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 @license |
| 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.g
ithub.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/CONTRI
BUTORS.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/PATEN
TS.txt |
| 9 --> |
| 10 |
| 11 <dom-module id="paper-spinner-styles"> |
| 12 <template> |
| 13 <style> |
| 14 /* |
| 15 /**************************/ |
| 16 /* STYLES FOR THE SPINNER */ |
| 17 /**************************/ |
| 18 |
| 19 /* |
| 20 * Constants: |
| 21 * STROKEWIDTH = 3px |
| 22 * ARCSIZE = 270 degrees (amount of circle the arc takes up) |
| 23 * ARCTIME = 1333ms (time it takes to expand and contract arc) |
| 24 * ARCSTARTROT = 216 degrees (how much the start location of the arc |
| 25 * should rotate each time, 216 gives us a |
| 26 * 5 pointed star shape (it's 360/5 * 3). |
| 27 * For a 7 pointed star, we might do |
| 28 * 360/7 * 3 = 154.286) |
| 29 * CONTAINERWIDTH = 28px |
| 30 * SHRINK_TIME = 400ms |
| 31 */ |
| 32 |
| 33 :host { |
| 34 display: inline-block; |
| 35 position: relative; |
| 36 width: 28px; /* CONTAINERWIDTH */ |
| 37 height: 28px; /* CONTAINERWIDTH */ |
| 38 } |
| 39 |
| 40 #spinnerContainer { |
| 41 width: 100%; |
| 42 height: 100%; |
| 43 |
| 44 /* The spinner does not have any contents that would have to be |
| 45 * flipped if the direction changes. Always use ltr so that the |
| 46 * style works out correctly in both cases. */ |
| 47 direction: ltr; |
| 48 } |
| 49 |
| 50 #spinnerContainer.active { |
| 51 /* duration: 360 * ARCTIME / (ARCSTARTROT + (360-ARCSIZE)) */ |
| 52 -webkit-animation: container-rotate 1568ms linear infinite; |
| 53 animation: container-rotate 1568ms linear infinite; |
| 54 } |
| 55 |
| 56 @-webkit-keyframes container-rotate { |
| 57 to { -webkit-transform: rotate(360deg) } |
| 58 } |
| 59 |
| 60 @keyframes container-rotate { |
| 61 to { transform: rotate(360deg) } |
| 62 } |
| 63 |
| 64 .spinner-layer { |
| 65 position: absolute; |
| 66 width: 100%; |
| 67 height: 100%; |
| 68 opacity: 0; |
| 69 white-space: nowrap; |
| 70 border-color: var(--paper-spinner-color, --google-blue-500); |
| 71 } |
| 72 |
| 73 .layer-1 { |
| 74 border-color: var(--paper-spinner-layer-1-color, --google-blue-500); |
| 75 } |
| 76 |
| 77 .layer-2 { |
| 78 border-color: var(--paper-spinner-layer-2-color, --google-red-500); |
| 79 } |
| 80 |
| 81 .layer-3 { |
| 82 border-color: var(--paper-spinner-layer-3-color, --google-yellow-500); |
| 83 } |
| 84 |
| 85 .layer-4 { |
| 86 border-color: var(--paper-spinner-layer-4-color, --google-green-500); |
| 87 } |
| 88 |
| 89 /** |
| 90 * IMPORTANT NOTE ABOUT CSS ANIMATION PROPERTIES (keanulee): |
| 91 * |
| 92 * iOS Safari (tested on iOS 8.1) does not handle animation-delay very wel
l - it doesn't |
| 93 * guarantee that the animation will start _exactly_ after that value. So
we avoid using |
| 94 * animation-delay and instead set custom keyframes for each color (as lay
er-2undant as it |
| 95 * seems). |
| 96 * |
| 97 * We write out each animation in full (instead of separating animation-na
me, |
| 98 * animation-duration, etc.) because under the polyfill, Safari does not r
ecognize those |
| 99 * specific properties properly, treats them as -webkit-animation, and ove
rrides the |
| 100 * other animation rules. See https://github.com/Polymer/platform/issues/5
3. |
| 101 */ |
| 102 .active .spinner-layer { |
| 103 /* durations: 4 * ARCTIME */ |
| 104 -webkit-animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2,
1) infinite both; |
| 105 animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infi
nite both; |
| 106 opacity: 1; |
| 107 } |
| 108 |
| 109 .active .spinner-layer.layer-1 { |
| 110 /* durations: 4 * ARCTIME */ |
| 111 -webkit-animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2,
1) infinite both, layer-1-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) inf
inite both; |
| 112 animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infi
nite both, layer-1-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite bo
th; |
| 113 } |
| 114 |
| 115 .active .spinner-layer.layer-2 { |
| 116 /* durations: 4 * ARCTIME */ |
| 117 -webkit-animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2,
1) infinite both, layer-2-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) inf
inite both; |
| 118 animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infi
nite both, layer-2-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite bo
th; |
| 119 } |
| 120 |
| 121 .active .spinner-layer.layer-3 { |
| 122 /* durations: 4 * ARCTIME */ |
| 123 -webkit-animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2,
1) infinite both, layer-3-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) inf
inite both; |
| 124 animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infi
nite both, layer-3-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite bo
th; |
| 125 } |
| 126 |
| 127 .active .spinner-layer.layer-4 { |
| 128 /* durations: 4 * ARCTIME */ |
| 129 -webkit-animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2,
1) infinite both, layer-4-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) inf
inite both; |
| 130 animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infi
nite both, layer-4-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite bo
th; |
| 131 } |
| 132 |
| 133 @-webkit-keyframes fill-unfill-rotate { |
| 134 12.5% { -webkit-transform: rotate(135deg); } /* 0.5 * ARCSIZE */ |
| 135 25% { -webkit-transform: rotate(270deg); } /* 1 * ARCSIZE */ |
| 136 37.5% { -webkit-transform: rotate(405deg); } /* 1.5 * ARCSIZE */ |
| 137 50% { -webkit-transform: rotate(540deg); } /* 2 * ARCSIZE */ |
| 138 62.5% { -webkit-transform: rotate(675deg); } /* 2.5 * ARCSIZE */ |
| 139 75% { -webkit-transform: rotate(810deg); } /* 3 * ARCSIZE */ |
| 140 87.5% { -webkit-transform: rotate(945deg); } /* 3.5 * ARCSIZE */ |
| 141 to { -webkit-transform: rotate(1080deg); } /* 4 * ARCSIZE */ |
| 142 } |
| 143 |
| 144 @keyframes fill-unfill-rotate { |
| 145 12.5% { transform: rotate(135deg); } /* 0.5 * ARCSIZE */ |
| 146 25% { transform: rotate(270deg); } /* 1 * ARCSIZE */ |
| 147 37.5% { transform: rotate(405deg); } /* 1.5 * ARCSIZE */ |
| 148 50% { transform: rotate(540deg); } /* 2 * ARCSIZE */ |
| 149 62.5% { transform: rotate(675deg); } /* 2.5 * ARCSIZE */ |
| 150 75% { transform: rotate(810deg); } /* 3 * ARCSIZE */ |
| 151 87.5% { transform: rotate(945deg); } /* 3.5 * ARCSIZE */ |
| 152 to { transform: rotate(1080deg); } /* 4 * ARCSIZE */ |
| 153 } |
| 154 |
| 155 /** |
| 156 * HACK: Even though the intention is to have the current .spinner-layer a
t |
| 157 * `opacity: 1`, we set it to `opacity: 0.99` instead since this forces Ch
rome |
| 158 * to do proper subpixel rendering for the elements being animated. This i
s |
| 159 * especially visible in Chrome 39 on Ubuntu 14.04. See: |
| 160 * |
| 161 * - https://github.com/Polymer/paper-spinner/issues/9 |
| 162 * - https://code.google.com/p/chromium/issues/detail?id=436255 |
| 163 */ |
| 164 @-webkit-keyframes layer-1-fade-in-out { |
| 165 from { opacity: 0.99; } |
| 166 25% { opacity: 0.99; } |
| 167 26% { opacity: 0; } |
| 168 89% { opacity: 0; } |
| 169 90% { opacity: 0.99; } |
| 170 100% { opacity: 0.99; } |
| 171 } |
| 172 |
| 173 @keyframes layer-1-fade-in-out { |
| 174 from { opacity: 0.99; } |
| 175 25% { opacity: 0.99; } |
| 176 26% { opacity: 0; } |
| 177 89% { opacity: 0; } |
| 178 90% { opacity: 0.99; } |
| 179 100% { opacity: 0.99; } |
| 180 } |
| 181 |
| 182 @-webkit-keyframes layer-2-fade-in-out { |
| 183 from { opacity: 0; } |
| 184 15% { opacity: 0; } |
| 185 25% { opacity: 0.99; } |
| 186 50% { opacity: 0.99; } |
| 187 51% { opacity: 0; } |
| 188 } |
| 189 |
| 190 @keyframes layer-2-fade-in-out { |
| 191 from { opacity: 0; } |
| 192 15% { opacity: 0; } |
| 193 25% { opacity: 0.99; } |
| 194 50% { opacity: 0.99; } |
| 195 51% { opacity: 0; } |
| 196 } |
| 197 |
| 198 @-webkit-keyframes layer-3-fade-in-out { |
| 199 from { opacity: 0; } |
| 200 40% { opacity: 0; } |
| 201 50% { opacity: 0.99; } |
| 202 75% { opacity: 0.99; } |
| 203 76% { opacity: 0; } |
| 204 } |
| 205 |
| 206 @keyframes layer-3-fade-in-out { |
| 207 from { opacity: 0; } |
| 208 40% { opacity: 0; } |
| 209 50% { opacity: 0.99; } |
| 210 75% { opacity: 0.99; } |
| 211 76% { opacity: 0; } |
| 212 } |
| 213 |
| 214 @-webkit-keyframes layer-4-fade-in-out { |
| 215 from { opacity: 0; } |
| 216 65% { opacity: 0; } |
| 217 75% { opacity: 0.99; } |
| 218 90% { opacity: 0.99; } |
| 219 100% { opacity: 0; } |
| 220 } |
| 221 |
| 222 @keyframes layer-4-fade-in-out { |
| 223 from { opacity: 0; } |
| 224 65% { opacity: 0; } |
| 225 75% { opacity: 0.99; } |
| 226 90% { opacity: 0.99; } |
| 227 100% { opacity: 0; } |
| 228 } |
| 229 |
| 230 /** |
| 231 * Patch the gap that appear between the two adjacent div.circle-clipper w
hile the |
| 232 * spinner is rotating (appears on Chrome 38, Safari 7.1, and IE 11). |
| 233 * |
| 234 * Update: the gap no longer appears on Chrome when .spinner-layer's opaci
ty is 0.99, |
| 235 * but still does on Safari and IE. |
| 236 */ |
| 237 .gap-patch { |
| 238 position: absolute; |
| 239 box-sizing: border-box; |
| 240 top: 0; |
| 241 left: 45%; |
| 242 width: 10%; |
| 243 height: 100%; |
| 244 overflow: hidden; |
| 245 border-color: inherit; |
| 246 } |
| 247 |
| 248 .gap-patch .circle { |
| 249 width: 1000%; |
| 250 left: -450%; |
| 251 } |
| 252 |
| 253 .circle-clipper { |
| 254 display: inline-block; |
| 255 position: relative; |
| 256 width: 50%; |
| 257 height: 100%; |
| 258 overflow: hidden; |
| 259 border-color: inherit; |
| 260 } |
| 261 |
| 262 .circle-clipper .circle { |
| 263 width: 200%; |
| 264 } |
| 265 |
| 266 .circle { |
| 267 box-sizing: border-box; |
| 268 height: 100%; |
| 269 border-width: 3px; /* STROKEWIDTH */ |
| 270 border-style: solid; |
| 271 border-color: inherit; |
| 272 border-bottom-color: transparent !important; |
| 273 border-radius: 50%; |
| 274 -webkit-animation: none; |
| 275 animation: none; |
| 276 |
| 277 @apply(--layout-fit); |
| 278 } |
| 279 |
| 280 .circle-clipper.left .circle { |
| 281 border-right-color: transparent !important; |
| 282 -webkit-transform: rotate(129deg); |
| 283 transform: rotate(129deg); |
| 284 } |
| 285 |
| 286 .circle-clipper.right .circle { |
| 287 left: -100%; |
| 288 border-left-color: transparent !important; |
| 289 -webkit-transform: rotate(-129deg); |
| 290 transform: rotate(-129deg); |
| 291 } |
| 292 |
| 293 .active .circle-clipper.left .circle { |
| 294 /* duration: ARCTIME */ |
| 295 -webkit-animation: left-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infin
ite both; |
| 296 animation: left-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both
; |
| 297 } |
| 298 |
| 299 .active .circle-clipper.right .circle { |
| 300 /* duration: ARCTIME */ |
| 301 -webkit-animation: right-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infi
nite both; |
| 302 animation: right-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite bot
h; |
| 303 } |
| 304 |
| 305 @-webkit-keyframes left-spin { |
| 306 from { -webkit-transform: rotate(130deg); } |
| 307 50% { -webkit-transform: rotate(-5deg); } |
| 308 to { -webkit-transform: rotate(130deg); } |
| 309 } |
| 310 |
| 311 @keyframes left-spin { |
| 312 from { transform: rotate(130deg); } |
| 313 50% { transform: rotate(-5deg); } |
| 314 to { transform: rotate(130deg); } |
| 315 } |
| 316 |
| 317 @-webkit-keyframes right-spin { |
| 318 from { -webkit-transform: rotate(-130deg); } |
| 319 50% { -webkit-transform: rotate(5deg); } |
| 320 to { -webkit-transform: rotate(-130deg); } |
| 321 } |
| 322 |
| 323 @keyframes right-spin { |
| 324 from { transform: rotate(-130deg); } |
| 325 50% { transform: rotate(5deg); } |
| 326 to { transform: rotate(-130deg); } |
| 327 } |
| 328 |
| 329 #spinnerContainer.cooldown { |
| 330 /* duration: SHRINK_TIME */ |
| 331 -webkit-animation: container-rotate 1568ms linear infinite, fade-out 400
ms cubic-bezier(0.4, 0.0, 0.2, 1); |
| 332 animation: container-rotate 1568ms linear infinite, fade-out 400ms cubic
-bezier(0.4, 0.0, 0.2, 1); |
| 333 } |
| 334 |
| 335 @-webkit-keyframes fade-out { |
| 336 from { opacity: 0.99; } |
| 337 to { opacity: 0; } |
| 338 } |
| 339 |
| 340 @keyframes fade-out { |
| 341 from { opacity: 0.99; } |
| 342 to { opacity: 0; } |
| 343 } |
| 344 </style> |
| 345 </template> |
| 346 </dom-module> |
OLD | NEW |