loading.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="container-main" v-if="show">
  3. <view class="loader">
  4. </view>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. props: {
  10. show: {
  11. type: Boolean,
  12. default: true
  13. }
  14. },
  15. onLoad(options) {
  16. },
  17. onShow() {
  18. },
  19. mounted() {
  20. },
  21. data() {
  22. return {
  23. }
  24. },
  25. methods: {
  26. }
  27. };
  28. </script>
  29. <style lang="scss">
  30. .container-main {
  31. height: 100vh;
  32. width: 100%;
  33. position: relative;
  34. z-index: 999;
  35. background-color: #fff;
  36. }
  37. $colors: hsla(337, 84, 48, 0.75) hsla(160, 50, 48, 0.75) hsla(190, 61, 65, 0.75) hsla(41, 82, 52, 0.75);
  38. $size: 2.5em;
  39. $thickness: 0.5em;
  40. // Calculated variables.
  41. $lat: ($size - $thickness) / 2;
  42. $offset: $lat - $thickness;
  43. .loader {
  44. position: relative;
  45. width: $size;
  46. height: $size;
  47. transform: rotate(165deg);
  48. &:before,
  49. &:after {
  50. content: '';
  51. position: absolute;
  52. top: 50%;
  53. left: 50%;
  54. display: block;
  55. width: $thickness;
  56. height: $thickness;
  57. border-radius: $thickness / 2;
  58. transform: translate(-50%, -50%);
  59. }
  60. &:before {
  61. animation: before 2s infinite;
  62. }
  63. &:after {
  64. animation: after 2s infinite;
  65. }
  66. }
  67. @keyframes before {
  68. 0% {
  69. width: $thickness;
  70. box-shadow:
  71. $lat (-$offset) nth($colors, 1),
  72. (-$lat) $offset nth($colors, 3);
  73. }
  74. 35% {
  75. width: $size;
  76. box-shadow:
  77. 0 (-$offset) nth($colors, 1),
  78. 0 $offset nth($colors, 3);
  79. }
  80. 70% {
  81. width: $thickness;
  82. box-shadow:
  83. (-$lat) (-$offset) nth($colors, 1),
  84. $lat $offset nth($colors, 3);
  85. }
  86. 100% {
  87. box-shadow:
  88. $lat (-$offset) nth($colors, 1),
  89. (-$lat) $offset nth($colors, 3);
  90. }
  91. }
  92. @keyframes after {
  93. 0% {
  94. height: $thickness;
  95. box-shadow:
  96. $offset $lat nth($colors, 2),
  97. (-$offset) (-$lat) nth($colors, 4);
  98. }
  99. 35% {
  100. height: $size;
  101. box-shadow:
  102. $offset 0 nth($colors, 2),
  103. (-$offset) 0 nth($colors, 4);
  104. }
  105. 70% {
  106. height: $thickness;
  107. box-shadow:
  108. $offset (-$lat) nth($colors, 2),
  109. (-$offset) $lat nth($colors, 4);
  110. }
  111. 100% {
  112. box-shadow:
  113. $offset $lat nth($colors, 2),
  114. (-$offset) (-$lat) nth($colors, 4);
  115. }
  116. }
  117. .loader {
  118. position: absolute;
  119. top: calc(50% - #{$size / 2});
  120. left: calc(50% - #{$size / 2});
  121. z-index: 999;
  122. }
  123. </style>