Last active
February 27, 2020 05:42
-
-
Save thelebster/945439f9a1d6b7ea09341bc8f214a9b3 to your computer and use it in GitHub Desktop.
Material Design Spinner (https://codepen.io/mrrocks/pen/EiplA)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <svg class="spinner" width="65px" height="65px" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg"> | |
| <circle class="path" fill="none" stroke-width="6" stroke-linecap="round" cx="33" cy="33" r="30"></circle> | |
| </svg> | |
| <style> | |
| // This is just to center the spinner | |
| html, body { height: 100%; } | |
| body { | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| } | |
| // Here is where the magic happens | |
| $offset: 187; | |
| $duration: 1.4s; | |
| .spinner { | |
| animation: rotator $duration linear infinite; | |
| } | |
| @keyframes rotator { | |
| 0% { transform: rotate(0deg); } | |
| 100% { transform: rotate(270deg); } | |
| } | |
| .path { | |
| stroke-dasharray: $offset; | |
| stroke-dashoffset: 0; | |
| transform-origin: center; | |
| animation: | |
| dash $duration ease-in-out infinite, | |
| colors ($duration*4) ease-in-out infinite; | |
| } | |
| @keyframes colors { | |
| 0% { stroke: #4285F4; } | |
| 25% { stroke: #DE3E35; } | |
| 50% { stroke: #F7C223; } | |
| 75% { stroke: #1B9A59; } | |
| 100% { stroke: #4285F4; } | |
| } | |
| @keyframes dash { | |
| 0% { stroke-dashoffset: $offset; } | |
| 50% { | |
| stroke-dashoffset: $offset/4; | |
| transform:rotate(135deg); | |
| } | |
| 100% { | |
| stroke-dashoffset: $offset; | |
| transform:rotate(450deg); | |
| } | |
| } | |
| </style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment