bounce.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view>
  3. <view
  4. class="spinner-inside"
  5. :style="{
  6. width: size + 110 + 'px'
  7. }"
  8. >
  9. <view :style="{ backgroundColor: color }" class="bounce1"></view>
  10. <view :style="{ backgroundColor: color }" class="bounce2"></view>
  11. <view :style="{ backgroundColor: color }" class="bounce3"></view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'bounce',
  18. props: {
  19. color: String,
  20. size: Number
  21. }
  22. };
  23. </script>
  24. <style scoped>
  25. .spinner-inside {
  26. margin: 25px auto;
  27. text-align: center;
  28. }
  29. .spinner-inside > view {
  30. width: 24px;
  31. height: 24px;
  32. margin-right: 4px;
  33. border-radius: 100%;
  34. display: inline-block;
  35. -webkit-animation: bouncedelay 1.4s infinite ease-in-out;
  36. animation: bouncedelay 1.4s infinite ease-in-out;
  37. /* Prevent first frame from flickering when animation starts */
  38. -webkit-animation-fill-mode: both;
  39. animation-fill-mode: both;
  40. }
  41. .spinner-inside .bounce1 {
  42. -webkit-animation-delay: -0.32s;
  43. animation-delay: -0.32s;
  44. }
  45. .spinner-inside .bounce2 {
  46. -webkit-animation-delay: -0.16s;
  47. animation-delay: -0.16s;
  48. }
  49. @-webkit-keyframes bouncedelay {
  50. 0%,
  51. 80%,
  52. 100% {
  53. -webkit-transform: scale(0);
  54. }
  55. 40% {
  56. -webkit-transform: scale(1);
  57. }
  58. }
  59. @keyframes bouncedelay {
  60. 0%,
  61. 80%,
  62. 100% {
  63. transform: scale(0);
  64. -webkit-transform: scale(0);
  65. }
  66. 40% {
  67. transform: scale(1);
  68. -webkit-transform: scale(1);
  69. }
  70. }
  71. </style>