Skip to content

Instantly share code, notes, and snippets.

@kevmul
Last active March 30, 2018 18:57
Show Gist options
  • Save kevmul/d538e26eb82d1d94d932ec84314d41e1 to your computer and use it in GitHub Desktop.
Save kevmul/d538e26eb82d1d94d932ec84314d41e1 to your computer and use it in GitHub Desktop.
This is a little toy loader built in Vue. Please try it out! Issues : The first column does not follow the correct timing If anyone has any ideas, let me know! :)
<template>
<div class="loader">
<div class="dotRow" v-for="(n, i) in dotColumns">
<div class="dot" v-for="(n, j) in dotCount" :style="breath(i,j)"></div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
dotColumns: 10,
dotCount: 10,
delay: 0
}
},
methods: {
breath(i, j) {
let time = 1/this.dotCount;
let dot = 0;
for(let n=1;n<=j;n++)
{
dot = time * (i + n)
console.log(n);
}
return `animation-delay: ${dot}s`
}
}
}
</script>
<style lang="sass">
.loader
display: block
margin: 50px auto
.dotRow
display: flex
width: 100px
flex-wrap: wrap
.dot
will-change: transform
will-change: color
display: block
background: purple
height: 10px
width: 10px
border-radius: 50%
animation: breath 4s ease infinite
@keyframes breath
0%
transform: scale(1)
20%
transform: scale(1.4)
background-color: lighten(purple,50%)
80%
transform: scale(1)
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment