Created
May 6, 2020 16:14
-
-
Save slightlyoff/f9a26ca6cf53799a506a30e29fec6222 to your computer and use it in GitHub Desktop.
TikTok spinner // source https://jsbin.com/hunutof
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>TikTok spinner</title> | |
<style> | |
:root { | |
--base: 4px; | |
--scale: 10; | |
--length: 1.4s; | |
--max-zoom: 1.2; | |
--min-zoom: 0.6; | |
--bg-color: black; | |
--green: rgb(145, 244, 239); | |
--red: rgb(219, 45, 82); | |
--radius: calc(var(--base) * var(--scale)); | |
--margin: var(--base); | |
--iradius: calc(var(--radius) - var(--margin)); | |
/* --ease: cubic-bezier(.05, 0, 1, 1); */ | |
--ease: linear; | |
} | |
body { | |
padding: 0px; | |
margin: 0px; | |
background: var(--bg-color); | |
height: 100vh; | |
width: 100vw; | |
/* center */ | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
} | |
.loading-container { | |
display: block; | |
width: 200px; | |
height: 100px; | |
} | |
.green { | |
fill: var(--green); | |
stroke-width: 0; | |
r: var(--iradius); | |
cx: calc(var(--radius)); | |
cy: calc(var(--radius) + var(--margin)); | |
animation: green var(--length) var(--ease) infinite; | |
} | |
.red { | |
fill: var(--red); | |
stroke-width: 0; | |
r: var(--iradius); | |
cx: calc(var(--radius) * 3); | |
cy: calc(var(--radius) + var(--margin)); | |
animation: red var(--length) var(--ease) infinite; | |
} | |
.black { | |
fill: black; | |
} | |
@keyframes green { | |
25% { | |
cx: calc(var(--radius) * 2); | |
r: calc(var(--iradius) * var(--max-zoom)); | |
} | |
50% { | |
cx: calc(var(--radius) * 3); | |
r: var(--iradius); | |
} | |
75% { | |
cx: calc(var(--radius) * 2); | |
r: calc(var(--iradius) * var(--min-zoom)); | |
} | |
100% { | |
cx: var(--radius); | |
r: var(--iradius); | |
} | |
} | |
@keyframes red { | |
25% { | |
cx: calc(var(--radius) * 2); | |
r: calc(var(--radius) * var(--min-zoom)); | |
} | |
50% { | |
cx: calc(var(--radius) * 1); | |
r: var(--iradius); | |
} | |
75% { | |
cx: calc(var(--radius) * 2); | |
r: calc(var(--iradius) * var(--max-zoom)); | |
} | |
100% { | |
cx: calc(var(--radius) * 3); | |
r: var(--iradius); | |
} | |
} | |
</style> | |
</head> | |
<body> | |
<svg class="loading-container" | |
preserveAspectRatio="none" | |
viewBox="0 0 200 100" | |
width="200" height="100"> | |
<defs> | |
<mask id="redhole"> | |
<rect width="100%" height="100%" fill="white"/> | |
<circle fill="black" class="red black"></circle> | |
</mask> | |
<mask id="greenhole"> | |
<rect width="100%" height="100%" fill="white"/> | |
<circle fill="black" class="green black"></circle> | |
</mask> | |
</defs> | |
<circle id="green" class="green" mask="url(#redhole)" ></circle> | |
<circle id="red" class="red" mask="url(#greenhole)" ></circle> | |
</svg> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment