_preloader.scss 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /*
  2. @license
  3. Copyright (c) 2014 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
  9. */
  10. /**************************/
  11. /* STYLES FOR THE SPINNER */
  12. /**************************/
  13. /*
  14. * Constants:
  15. * STROKEWIDTH = 3px
  16. * ARCSIZE = 270 degrees (amount of circle the arc takes up)
  17. * ARCTIME = 1333ms (time it takes to expand and contract arc)
  18. * ARCSTARTROT = 216 degrees (how much the start location of the arc
  19. * should rotate each time, 216 gives us a
  20. * 5 pointed star shape (it's 360/5 * 3).
  21. * For a 7 pointed star, we might do
  22. * 360/7 * 3 = 154.286)
  23. * CONTAINERWIDTH = 28px
  24. * SHRINK_TIME = 400ms
  25. */
  26. .preloader-wrapper {
  27. display: inline-block;
  28. position: relative;
  29. width: 50px;
  30. height: 50px;
  31. &.small {
  32. width: 36px;
  33. height: 36px;
  34. }
  35. &.big {
  36. width: 64px;
  37. height: 64px;
  38. }
  39. &.active {
  40. /* duration: 360 * ARCTIME / (ARCSTARTROT + (360-ARCSIZE)) */
  41. -webkit-animation: container-rotate 1568ms linear infinite;
  42. animation: container-rotate 1568ms linear infinite;
  43. }
  44. }
  45. @-webkit-keyframes container-rotate {
  46. to { -webkit-transform: rotate(360deg) }
  47. }
  48. @keyframes container-rotate {
  49. to { transform: rotate(360deg) }
  50. }
  51. .spinner-layer {
  52. position: absolute;
  53. width: 100%;
  54. height: 100%;
  55. opacity: 0;
  56. border-color: $spinner-default-color;
  57. }
  58. .spinner-blue,
  59. .spinner-blue-only {
  60. border-color: #4285f4;
  61. }
  62. .spinner-red,
  63. .spinner-red-only {
  64. border-color: #db4437;
  65. }
  66. .spinner-yellow,
  67. .spinner-yellow-only {
  68. border-color: #f4b400;
  69. }
  70. .spinner-green,
  71. .spinner-green-only {
  72. border-color: #0f9d58;
  73. }
  74. /**
  75. * IMPORTANT NOTE ABOUT CSS ANIMATION PROPERTIES (keanulee):
  76. *
  77. * iOS Safari (tested on iOS 8.1) does not handle animation-delay very well - it doesn't
  78. * guarantee that the animation will start _exactly_ after that value. So we avoid using
  79. * animation-delay and instead set custom keyframes for each color (as redundant as it
  80. * seems).
  81. *
  82. * We write out each animation in full (instead of separating animation-name,
  83. * animation-duration, etc.) because under the polyfill, Safari does not recognize those
  84. * specific properties properly, treats them as -webkit-animation, and overrides the
  85. * other animation rules. See https://github.com/Polymer/platform/issues/53.
  86. */
  87. .active .spinner-layer.spinner-blue {
  88. /* durations: 4 * ARCTIME */
  89. -webkit-animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both, blue-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  90. animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both, blue-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  91. }
  92. .active .spinner-layer.spinner-red {
  93. /* durations: 4 * ARCTIME */
  94. -webkit-animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both, red-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  95. animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both, red-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  96. }
  97. .active .spinner-layer.spinner-yellow {
  98. /* durations: 4 * ARCTIME */
  99. -webkit-animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both, yellow-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  100. animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both, yellow-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  101. }
  102. .active .spinner-layer.spinner-green {
  103. /* durations: 4 * ARCTIME */
  104. -webkit-animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both, green-fade-in-out 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) infinite both, green-fade-in-out 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  106. }
  107. .active .spinner-layer,
  108. .active .spinner-layer.spinner-blue-only,
  109. .active .spinner-layer.spinner-red-only,
  110. .active .spinner-layer.spinner-yellow-only,
  111. .active .spinner-layer.spinner-green-only {
  112. /* durations: 4 * ARCTIME */
  113. opacity: 1;
  114. -webkit-animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  115. animation: fill-unfill-rotate 5332ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  116. }
  117. @-webkit-keyframes fill-unfill-rotate {
  118. 12.5% { -webkit-transform: rotate(135deg); } /* 0.5 * ARCSIZE */
  119. 25% { -webkit-transform: rotate(270deg); } /* 1 * ARCSIZE */
  120. 37.5% { -webkit-transform: rotate(405deg); } /* 1.5 * ARCSIZE */
  121. 50% { -webkit-transform: rotate(540deg); } /* 2 * ARCSIZE */
  122. 62.5% { -webkit-transform: rotate(675deg); } /* 2.5 * ARCSIZE */
  123. 75% { -webkit-transform: rotate(810deg); } /* 3 * ARCSIZE */
  124. 87.5% { -webkit-transform: rotate(945deg); } /* 3.5 * ARCSIZE */
  125. to { -webkit-transform: rotate(1080deg); } /* 4 * ARCSIZE */
  126. }
  127. @keyframes fill-unfill-rotate {
  128. 12.5% { transform: rotate(135deg); } /* 0.5 * ARCSIZE */
  129. 25% { transform: rotate(270deg); } /* 1 * ARCSIZE */
  130. 37.5% { transform: rotate(405deg); } /* 1.5 * ARCSIZE */
  131. 50% { transform: rotate(540deg); } /* 2 * ARCSIZE */
  132. 62.5% { transform: rotate(675deg); } /* 2.5 * ARCSIZE */
  133. 75% { transform: rotate(810deg); } /* 3 * ARCSIZE */
  134. 87.5% { transform: rotate(945deg); } /* 3.5 * ARCSIZE */
  135. to { transform: rotate(1080deg); } /* 4 * ARCSIZE */
  136. }
  137. @-webkit-keyframes blue-fade-in-out {
  138. from { opacity: 1; }
  139. 25% { opacity: 1; }
  140. 26% { opacity: 0; }
  141. 89% { opacity: 0; }
  142. 90% { opacity: 1; }
  143. 100% { opacity: 1; }
  144. }
  145. @keyframes blue-fade-in-out {
  146. from { opacity: 1; }
  147. 25% { opacity: 1; }
  148. 26% { opacity: 0; }
  149. 89% { opacity: 0; }
  150. 90% { opacity: 1; }
  151. 100% { opacity: 1; }
  152. }
  153. @-webkit-keyframes red-fade-in-out {
  154. from { opacity: 0; }
  155. 15% { opacity: 0; }
  156. 25% { opacity: 1; }
  157. 50% { opacity: 1; }
  158. 51% { opacity: 0; }
  159. }
  160. @keyframes red-fade-in-out {
  161. from { opacity: 0; }
  162. 15% { opacity: 0; }
  163. 25% { opacity: 1; }
  164. 50% { opacity: 1; }
  165. 51% { opacity: 0; }
  166. }
  167. @-webkit-keyframes yellow-fade-in-out {
  168. from { opacity: 0; }
  169. 40% { opacity: 0; }
  170. 50% { opacity: 1; }
  171. 75% { opacity: 1; }
  172. 76% { opacity: 0; }
  173. }
  174. @keyframes yellow-fade-in-out {
  175. from { opacity: 0; }
  176. 40% { opacity: 0; }
  177. 50% { opacity: 1; }
  178. 75% { opacity: 1; }
  179. 76% { opacity: 0; }
  180. }
  181. @-webkit-keyframes green-fade-in-out {
  182. from { opacity: 0; }
  183. 65% { opacity: 0; }
  184. 75% { opacity: 1; }
  185. 90% { opacity: 1; }
  186. 100% { opacity: 0; }
  187. }
  188. @keyframes green-fade-in-out {
  189. from { opacity: 0; }
  190. 65% { opacity: 0; }
  191. 75% { opacity: 1; }
  192. 90% { opacity: 1; }
  193. 100% { opacity: 0; }
  194. }
  195. /**
  196. * Patch the gap that appear between the two adjacent div.circle-clipper while the
  197. * spinner is rotating (appears on Chrome 38, Safari 7.1, and IE 11).
  198. */
  199. .gap-patch {
  200. position: absolute;
  201. top: 0;
  202. left: 45%;
  203. width: 10%;
  204. height: 100%;
  205. overflow: hidden;
  206. border-color: inherit;
  207. }
  208. .gap-patch .circle {
  209. width: 1000%;
  210. left: -450%;
  211. }
  212. .circle-clipper {
  213. display: inline-block;
  214. position: relative;
  215. width: 50%;
  216. height: 100%;
  217. overflow: hidden;
  218. border-color: inherit;
  219. .circle {
  220. width: 200%;
  221. height: 100%;
  222. border-width: 3px; /* STROKEWIDTH */
  223. border-style: solid;
  224. border-color: inherit;
  225. border-bottom-color: transparent !important;
  226. border-radius: 50%;
  227. -webkit-animation: none;
  228. animation: none;
  229. position: absolute;
  230. top: 0;
  231. right: 0;
  232. bottom: 0;
  233. }
  234. &.left .circle {
  235. left: 0;
  236. border-right-color: transparent !important;
  237. -webkit-transform: rotate(129deg);
  238. transform: rotate(129deg);
  239. }
  240. &.right .circle {
  241. left: -100%;
  242. border-left-color: transparent !important;
  243. -webkit-transform: rotate(-129deg);
  244. transform: rotate(-129deg);
  245. }
  246. }
  247. .active .circle-clipper.left .circle {
  248. /* duration: ARCTIME */
  249. -webkit-animation: left-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  250. animation: left-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  251. }
  252. .active .circle-clipper.right .circle {
  253. /* duration: ARCTIME */
  254. -webkit-animation: right-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  255. animation: right-spin 1333ms cubic-bezier(0.4, 0.0, 0.2, 1) infinite both;
  256. }
  257. @-webkit-keyframes left-spin {
  258. from { -webkit-transform: rotate(130deg); }
  259. 50% { -webkit-transform: rotate(-5deg); }
  260. to { -webkit-transform: rotate(130deg); }
  261. }
  262. @keyframes left-spin {
  263. from { transform: rotate(130deg); }
  264. 50% { transform: rotate(-5deg); }
  265. to { transform: rotate(130deg); }
  266. }
  267. @-webkit-keyframes right-spin {
  268. from { -webkit-transform: rotate(-130deg); }
  269. 50% { -webkit-transform: rotate(5deg); }
  270. to { -webkit-transform: rotate(-130deg); }
  271. }
  272. @keyframes right-spin {
  273. from { transform: rotate(-130deg); }
  274. 50% { transform: rotate(5deg); }
  275. to { transform: rotate(-130deg); }
  276. }
  277. #spinnerContainer.cooldown {
  278. /* duration: SHRINK_TIME */
  279. -webkit-animation: container-rotate 1568ms linear infinite, fade-out 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
  280. animation: container-rotate 1568ms linear infinite, fade-out 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
  281. }
  282. @-webkit-keyframes fade-out {
  283. from { opacity: 1; }
  284. to { opacity: 0; }
  285. }
  286. @keyframes fade-out {
  287. from { opacity: 1; }
  288. to { opacity: 0; }
  289. }