Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

looping-rhombuses-spinner

v1.1.0arrow_drop_down
v1.1.0
STATUS
Passing
DOWNLOADS
5
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
A year ago
SIZE
3 KB
1 contributor
Install looping-rhombuses-spinner as a package?
Copied
npm i @bit/epicmaxco.epic-spinners.looping-rhombuses-spinner
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Files
LoopingRhombusesSpinner.vue
118 Lines(102 sloc)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
  <div class="looping-rhombuses-spinner" :style="spinnerStyle">
    <div class="rhombus"
         v-for="(rs, index) in rhombusesStyles"
         :ikey="index"
         :style="rs">
    </div>
  </div>
</template>

<script>
  export default {
    name: 'LoopingRhombusesSpinner',

    props: {
      animationDuration: {
        type: Number,
        default: 2500
      },
      rhombusSize: {
        type: Number,
        default: 15
      },
      color: {
        type: String,
        default: '#fff'
      }
    },

    data () {
      return {
        rhombusesNum: 3
      }
    },

    computed: {
      spinnerStyle () {
        return {
          height: `${this.rhombusSize}px`,
          width: `${this.rhombusSize * 4}px`
        }
      },

      rhombusStyle () {
        return {
          height: `${this.rhombusSize}px`,
          width: `${this.rhombusSize}px`,
          backgroundColor: this.color,
          animationDuration: `${this.animationDuration}ms`,
          left: `${this.rhombusSize * 4}px`
        }
      },

      rhombusesStyles () {
        const rhombusesStyles = []
        const delay = -this.animationDuration / 1.5

        for (let i = 1; i <= this.rhombusesNum; i++) {
          const style = Object.assign({
            animationDelay: `${i * delay}ms`
          }, this.rhombusStyle)

          rhombusesStyles.push(style)
        }

        return rhombusesStyles
      }
    }
  }
</script>

<style scoped>
  .looping-rhombuses-spinner, .looping-rhombuses-spinner * {
    box-sizing: border-box;
  }

  .looping-rhombuses-spinner {
    width: calc(15px * 4);
    height: 15px;
    position: relative;
  }

  .looping-rhombuses-spinner .rhombus {
    height: 15px;
    width: 15px;
    background-color: #ff1d5e;
    left: calc(15px * 4);
    position: absolute;
    margin: 0 auto;
    border-radius: 2px;
    transform: translateY(0) rotate(45deg) scale(0);
    animation: looping-rhombuses-spinner-animation 2500ms linear infinite;
  }

  .looping-rhombuses-spinner .rhombus:nth-child(1) {
    animation-delay: calc(2500ms * 1 / -1.5);
  }

  .looping-rhombuses-spinner .rhombus:nth-child(2) {
    animation-delay: calc(2500ms * 2 / -1.5);
  }

  .looping-rhombuses-spinner .rhombus:nth-child(3) {
    animation-delay: calc(2500ms * 3 / -1.5);
  }

  @keyframes looping-rhombuses-spinner-animation {
    0% {
      transform: translateX(0) rotate(45deg) scale(0);
    }
    50% {
      transform: translateX(-233%) rotate(45deg) scale(1);
    }
    100% {
      transform: translateX(-466%) rotate(45deg) scale(0);
    }
  }
</style>