Watch interactive video on Scrimba: https://scrimba.com/p/pEgDAM/cVB48Ur
Created
May 21, 2019 22:22
-
-
Save shshaw/1e8b1e364d642cd5c42ea768fe47ec56 to your computer and use it in GitHub Desktop.
Colorful bar loader
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
<div class="loader"></div> |
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
const COUNT = 360 / 12; | |
d3.select('.loader') | |
.selectAll('span') | |
.data(d3.range(COUNT).map(d => d + 1)) | |
.enter() | |
.append('span') | |
.style('background-color', (d) => d % 2 !== 0 | |
? `hsl(${d * 12}, 100%, 65%)` | |
: 'black'); | |
let animation = new TimelineMax({repeat: -1}); | |
animation.staggerFrom('.loader span', 0.5, {scaleX: 0}, 0.4) |
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
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.0.2/TweenMax.min.js"></script> |
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
body { | |
margin: 0; | |
height: 100vh; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
background-color: black; | |
} | |
.loader { | |
width: 40em; | |
height: 1em; | |
font-size: 10px; | |
position: relative; | |
} | |
.loader span { | |
position: absolute; | |
width: inherit; | |
height: inherit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment