Spinner.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template lang="pug">
  2. .spinner(v-if="type === 'wave'")
  3. .spinner-rect.spinner-rect-1
  4. .spinner-rect.spinner-rect-2
  5. .spinner-rect.spinner-rect-3
  6. .spinner-rect.spinner-rect-4
  7. .spinner-rect.spinner-rect-5
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. type: String,
  13. default: 'wave'
  14. }
  15. }
  16. </script>
  17. <style lang="sass">
  18. @import '../../assets/variables'
  19. .spinner
  20. $rect-count: 5
  21. $animation-duration: 1000ms
  22. $delay-range: 400ms
  23. width: 50px
  24. height: 40px
  25. text-align: center
  26. font-size: 10px
  27. margin: 40px auto
  28. .spinner-rect
  29. width: 5px
  30. height: 100%
  31. background: $app-main-color
  32. margin: 0 3px 0 0
  33. display: inline-block
  34. animation: spinner-wave $animation-duration infinite ease-in-out
  35. @for $i from 1 through $rect-count
  36. .spinner-rect-#{$i}
  37. animation-delay: - $animation-duration + $delay-range / ($rect-count - 1) * ($i - 1)
  38. @keyframes spinner-wave
  39. 0%, 40%, 100%
  40. transform: scaleY(0.4)
  41. 20%
  42. transform: scaleY(1.0)
  43. </style>