loading.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div class="spinner-box" v-show="loading">
  3. <div class="spinner-inner" :style="{color: color}">
  4. <div class="la-ball-beat">
  5. <div :style="spinnerStyle"/>
  6. <div :style="spinnerStyle"/>
  7. <div :style="spinnerStyle"/>
  8. </div>
  9. <slot/>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'Loader',
  16. props: {
  17. loading: {
  18. type: Boolean,
  19. default: true
  20. },
  21. color: {
  22. type: String,
  23. default: 'rgba(197, 197, 197, 0.4)'
  24. },
  25. height: {
  26. type: String,
  27. default: '15px'
  28. },
  29. width: {
  30. type: String,
  31. default: '15px'
  32. },
  33. margin: {
  34. type: String,
  35. default: '5px'
  36. }
  37. },
  38. data () {
  39. return {
  40. spinnerStyle: {
  41. backgroundColor: this.color,
  42. height: this.height,
  43. width: this.width,
  44. margin: this.margin
  45. }
  46. }
  47. }
  48. }
  49. </script>
  50. <style lang="scss" scoped>
  51. @import '~assets/scss/mixins';
  52. @import '~assets/scss/variables';
  53. .spinner-box {
  54. position: relative;
  55. width: 100%;
  56. min-height: 50px;
  57. height: 100%;
  58. > .spinner-inner {
  59. width: 80px;
  60. height: 30px;
  61. position: absolute;
  62. top: 50%;
  63. left: 50%;
  64. margin-left: -40px;
  65. margin-top: -15px;
  66. text-align: center;
  67. > .la-ball-beat {
  68. display: block;
  69. position: relative;
  70. box-sizing: border-box;
  71. font-size: 0;
  72. color: #fff;
  73. width: 80px;
  74. height: 30px;
  75. > div {
  76. position: relative;
  77. box-sizing: border-box;
  78. display: inline-block;
  79. float: none;
  80. border: none;
  81. width: 15px;
  82. height: 15px;
  83. margin: 5px;
  84. background-color: $module-hover-bg;
  85. @include css3-prefix(animation, ball-beat 0.7s -0.15s infinite linear);
  86. &:nth-child(2n-1) {
  87. @include css3-prefix(animation-delay, -.5s);
  88. }
  89. }
  90. &.la-sm {
  91. width: 26px;
  92. height: 8px;
  93. > div {
  94. width: 8px;
  95. height: 8px;
  96. margin: 3px;
  97. }
  98. }
  99. &.la-2x {
  100. width: 108px;
  101. height: 36px;
  102. > div {
  103. width: 20px;
  104. height: 20px;
  105. margin: 8px;
  106. }
  107. }
  108. &.la-3x {
  109. width: 162px;
  110. height: 54px;
  111. > div {
  112. width: 30px;
  113. height: 30px;
  114. margin: 12px
  115. }
  116. }
  117. }
  118. }
  119. }
  120. @include keyframes(ball-beat) {
  121. 50% {
  122. opacity: .2;
  123. @include css3-prefix(transform, scale(0.75));
  124. }
  125. 100% {
  126. opacity: 1;
  127. @include css3-prefix(transform, scale(1));
  128. }
  129. }
  130. </style>