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

hollow-dots-spinner

v1.1.0arrow_drop_down
v1.1.0
STATUS
Passing
DOWNLOADS
10
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
10 months ago
SIZE
3 KB
1 contributor
Install hollow-dots-spinner as a package?
Copied
npm i @bit/epicmaxco.epic-spinners.hollow-dots-spinner
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Files
HollowDotsSpinner.vue
115 Lines(98 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
<template>
  <div class="hollow-dots-spinner" :style="spinnerStyle">
    <div class="dot" v-for="(ds, index) in dotsStyles" :style="ds" :key="index"></div>
  </div>
</template>

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

    props: {
      animationDuration: {
        type: Number,
        default: 1000
      },
      dotSize: {
        type: Number,
        default: 15
      },
      dotsNum: {
        type: Number,
        default: 3
      },
      color: {
        type: String,
        default: '#fff'
      }
    },

    computed: {
      horizontalMargin () {
        return this.dotSize / 2
      },

      spinnerStyle () {
        return {
          height: `${this.dotSize}px`,
          width: `${(this.dotSize + this.horizontalMargin * 2) * this.dotsNum}px`
        }
      },

      dotStyle () {
        return {
          animationDuration: `${this.animationDuration}ms`,
          width: `${this.dotSize}px`,
          height: `${this.dotSize}px`,
          margin: `0 ${this.horizontalMargin}px`,
          borderWidth: `${this.dotSize / 5}px`,
          borderColor: this.color
        }
      },

      dotsStyles () {
        const dotsStyles = []
        const delayModifier = 0.3
        const basicDelay = 1000

        for (let i = 1; i <= this.dotsNum; i++) {
          const style = Object.assign({
            animationDelay: `${basicDelay * i * delayModifier}ms`
          }, this.dotStyle)

          dotsStyles.push(style)
        }

        return dotsStyles
      }
    }
  }
</script>

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

  .hollow-dots-spinner {
    height: 15px;
    width: calc(30px * 3);
  }

  .hollow-dots-spinner .dot {
    width: 15px;
    height: 15px;
    margin: 0 calc(15px / 2);
    border: calc(15px / 5) solid #ff1d5e;
    border-radius: 50%;
    float: left;
    transform: scale(0);
    animation: hollow-dots-spinner-animation 1000ms ease infinite 0ms;
  }

  .hollow-dots-spinner .dot:nth-child(1) {
    animation-delay: calc(300ms * 1);
  }

  .hollow-dots-spinner .dot:nth-child(2) {
    animation-delay: calc(300ms * 2);
  }

  .hollow-dots-spinner .dot:nth-child(3) {
    animation-delay: calc(300ms * 3);

  }

  @keyframes hollow-dots-spinner-animation {
    50% {
      transform: scale(1);
      opacity: 1;
    }
    100% {
      opacity: 0;
    }
  }
</style>