index.less 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. @import '../style/var';
  2. .van-loading {
  3. width: 30px;
  4. height: 30px;
  5. z-index: 0;
  6. font-size: 0;
  7. line-height: 0;
  8. position: relative;
  9. vertical-align: middle;
  10. &--circle {
  11. width: 16px;
  12. height: 16px;
  13. }
  14. &__spinner {
  15. z-index: -1;
  16. width: 100%;
  17. height: 100%;
  18. position: relative;
  19. display: inline-block;
  20. box-sizing: border-box;
  21. animation: van-rotate 0.8s linear infinite;
  22. &--circle {
  23. border-radius: 100%;
  24. border: 3px solid transparent;
  25. border-color: @gray;
  26. border-top-color: @gray-darker;
  27. }
  28. &--gradient-circle {
  29. background-size: contain;
  30. background-image: url('https://img.yzcdn.cn/vant/gradient-circle-black.png');
  31. }
  32. &--spinner {
  33. animation-timing-function: steps(12);
  34. i {
  35. top: 0;
  36. left: 0;
  37. width: 100%;
  38. height: 100%;
  39. position: absolute;
  40. &::before {
  41. width: 2px;
  42. height: 25%;
  43. content: ' ';
  44. display: block;
  45. margin: 0 auto;
  46. border-radius: 40%;
  47. background-color: currentColor;
  48. }
  49. }
  50. }
  51. &--circular {
  52. animation-duration: 2s;
  53. }
  54. }
  55. &__circular {
  56. width: 100%;
  57. height: 100%;
  58. circle {
  59. stroke: currentColor;
  60. stroke-width: 3;
  61. stroke-linecap: round;
  62. animation: van-circular 1.5s ease-in-out infinite;
  63. }
  64. }
  65. &--white {
  66. .van-loading__spinner--circle {
  67. border-color: rgba(0, 0, 0, .1);
  68. border-top-color: rgba(255, 255, 255, .7);
  69. }
  70. .van-loading__spinner--gradient-circle {
  71. background-image: url('https://img.yzcdn.cn/vant/gradient-circle-white.png');
  72. }
  73. }
  74. }
  75. @keyframes van-circular {
  76. 0% {
  77. stroke-dasharray: 1, 200;
  78. stroke-dashoffset: 0;
  79. }
  80. 50% {
  81. stroke-dasharray: 90, 150;
  82. stroke-dashoffset: -40;
  83. }
  84. 100% {
  85. stroke-dasharray: 90, 150;
  86. stroke-dashoffset: -120;
  87. }
  88. }
  89. .generate-spinner(@n, @i: 1) when (@i =< @n) {
  90. .van-loading__spinner--spinner i:nth-of-type(@{i}) {
  91. opacity: 1 - (0.75 / 12) * (@i - 1);
  92. transform: rotate(@i * 30deg);
  93. }
  94. .generate-spinner(@n, (@i + 1));
  95. }
  96. .generate-spinner(12);