digitalScrollersComp.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div class="count-flop" :key="compKey">
  3. <!-- -->
  4. <div
  5. :class="item !== ',' ? 'count-flop-box' : 'count-flop-point'"
  6. v-for="(item, index) in value"
  7. :key="index"
  8. >
  9. <div>
  10. <div v-if="item !== ','" class="count-flop-content" :class="['rolling_' + item]">
  11. <div v-for="(item2, index2) in numberList" :key="index2" class="count-flop-num">
  12. {{ item2 }}
  13. </div>
  14. </div>
  15. <div v-else class="count-flop-content">,</div>
  16. </div>
  17. </div>
  18. <!-- -->
  19. <div v-if="suffix" class="count-flop-unit">{{ suffix }}</div>
  20. </div>
  21. </template>
  22. <script setup>
  23. import { ref, watch, onMounted } from 'vue'
  24. const props = defineProps({
  25. val: {
  26. type: [Number, String],
  27. default: 0,
  28. },
  29. suffix: {
  30. type: String,
  31. default: "",
  32. },
  33. });
  34. // Data
  35. const value = ref([]);
  36. const numberList = ref([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
  37. const compKey = ref(0);
  38. // Watcher
  39. watch(
  40. () => props.val,
  41. (newVal) => {
  42. value.value = newVal.toString().split("");
  43. compKey.value += 1;
  44. },
  45. { immediate: true },
  46. );
  47. </script>
  48. <style scoped>
  49. .count-flop {
  50. display: inline-block;
  51. font-size: 0;
  52. /* 可更改 */
  53. height: 80px;
  54. line-height: 80px;
  55. font-size: 50px;
  56. font-weight: 700;
  57. color: #ffffff;
  58. }
  59. .count-flop > div {
  60. position: relative;
  61. display: inline-block;
  62. overflow: hidden;
  63. height: 100%;
  64. }
  65. .count-flop-box {
  66. /* 可更改 */
  67. margin-right: 5px;
  68. width: 60px;
  69. color: #ffffff;
  70. /* background-color: rgba(6, 41, 78, 0.7); */
  71. border: 1px solid #2663a5;
  72. /* box-shadow: 0 2px 5px #2663a5; */
  73. /* line-height: 98px; */
  74. border: 2px solid transparent;
  75. border-radius: 8px;
  76. background-clip: padding-box, border-box;
  77. background-origin: padding-box, border-box;
  78. background-image: linear-gradient(128deg, #00002d, #2220), linear-gradient(136deg, #e5e5e5de, #00000000, #00000000, #00000000);
  79. }
  80. .count-flop-point {
  81. /* 可更改 */
  82. margin-right: 5px;
  83. width: 15px;
  84. }
  85. .count-flop-content {
  86. font-family: 'din-bold';
  87. text-align: center;
  88. position: absolute;
  89. left: 0;
  90. top: 0;
  91. width: 100%;
  92. animation-fill-mode: forwards !important;
  93. }
  94. .rolling_0 {
  95. animation: rolling_0 2.1s ease;
  96. }
  97. @keyframes rolling_0 {
  98. from {
  99. transform: translateY(-90%);
  100. }
  101. to {
  102. transform: translateY(0);
  103. }
  104. }
  105. .rolling_1 {
  106. animation: rolling_1 3s ease;
  107. }
  108. @keyframes rolling_1 {
  109. from {
  110. transform: translateY(0);
  111. }
  112. to {
  113. transform: translateY(-10%);
  114. }
  115. }
  116. .rolling_2 {
  117. animation: rolling_2 2.1s ease;
  118. }
  119. @keyframes rolling_2 {
  120. from {
  121. transform: translateY(0);
  122. }
  123. to {
  124. transform: translateY(-20%);
  125. }
  126. }
  127. .rolling_3 {
  128. animation: rolling_3 3s ease;
  129. }
  130. @keyframes rolling_3 {
  131. from {
  132. transform: translateY(0);
  133. }
  134. to {
  135. transform: translateY(-30%);
  136. }
  137. }
  138. .rolling_4 {
  139. animation: rolling_4 2.1s ease;
  140. }
  141. @keyframes rolling_4 {
  142. from {
  143. transform: translateY(0);
  144. }
  145. to {
  146. transform: translateY(-40%);
  147. }
  148. }
  149. .rolling_5 {
  150. animation: rolling_5 3s ease;
  151. }
  152. @keyframes rolling_5 {
  153. from {
  154. transform: translateY(0);
  155. }
  156. to {
  157. transform: translateY(-50%);
  158. }
  159. }
  160. .rolling_6 {
  161. animation: rolling_6 2.1s ease;
  162. }
  163. @keyframes rolling_6 {
  164. from {
  165. transform: translateY(0);
  166. }
  167. to {
  168. transform: translateY(-60%);
  169. }
  170. }
  171. .rolling_7 {
  172. animation: rolling_7 3.1s ease;
  173. }
  174. @keyframes rolling_7 {
  175. from {
  176. transform: translateY(0);
  177. }
  178. to {
  179. transform: translateY(-70%);
  180. }
  181. }
  182. .rolling_8 {
  183. animation: rolling_8 2.1s ease;
  184. }
  185. @keyframes rolling_8 {
  186. from {
  187. transform: translateY(0);
  188. }
  189. to {
  190. transform: translateY(-80%);
  191. }
  192. }
  193. .rolling_9 {
  194. animation: rolling_9 3.6s ease;
  195. }
  196. @keyframes rolling_9 {
  197. from {
  198. transform: translateY(0);
  199. }
  200. to {
  201. transform: translateY(-90%);
  202. }
  203. }
  204. /* 其他 rolling_X 动画略 */
  205. </style>