jump-loader.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="text-container">
  3. <view class="wave-wrapper">
  4. <view class="wave-text-box" ref="waveBox">
  5. <text class="wave-text" :style="{ fontSize: fontSize + 'rpx', color: color }">{{ text }}</text>
  6. </view>
  7. <!-- #ifndef APP-NVUE -->
  8. <view class="wave-pallet" ref="wavePallet"></view>
  9. <!-- #endif -->
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. // ls-loading组件内置动画效果组件: 文字跳动动画组件
  15. // #ifdef APP-NVUE
  16. const animation = weex.requireModule('animation');
  17. // #endif
  18. let sit;
  19. export default {
  20. name: 'jump-loader',
  21. props: {
  22. // 加载中的文字
  23. text: {
  24. type: String,
  25. default: '正在加载'
  26. },
  27. // 加载中文字大小
  28. fontSize: {
  29. type: [String, Number],
  30. default: 58
  31. },
  32. color: {
  33. type: String,
  34. default: '#c7c6c7'
  35. }
  36. },
  37. mounted() {
  38. setTimeout(() => {
  39. // #ifdef APP-NVUE
  40. this.createAnimation();
  41. // #endif
  42. }, 100);
  43. },
  44. destroyed() {
  45. clearInterval(sit);
  46. },
  47. methods: {
  48. createAnimation() {
  49. let textTransform = 'translateY(0)';
  50. let flag = true;
  51. this.executeTextAnimation('translateY(-90%)');
  52. clearInterval(sit);
  53. sit = setInterval(() => {
  54. textTransform = flag ? 'translateY(0)' : 'translateY(-90%)';
  55. this.executeTextAnimation(textTransform);
  56. flag = !flag;
  57. }, 1000);
  58. },
  59. // 文字动画
  60. executeTextAnimation(transform) {
  61. animation.transition(this.$refs.waveBox, {
  62. styles: {
  63. transform
  64. },
  65. duration: 1000, //ms
  66. timingFunction: 'ease-in-out',
  67. needLayout: false,
  68. delay: 0 //ms
  69. });
  70. },
  71. }
  72. };
  73. </script>
  74. <style>
  75. .text-container {
  76. /* #ifndef APP-NVUE */
  77. display: flex;
  78. /* #endif */
  79. flex: 1;
  80. flex-direction: column;
  81. align-items: center;
  82. justify-content: center;
  83. position: relative;
  84. }
  85. .wave-wrapper {
  86. position: relative;
  87. /* #ifndef APP-NVUE */
  88. display: flex;
  89. overflow: visible;
  90. /* #endif */
  91. /* #ifdef APP-NVUE */
  92. height: 50vh;
  93. flex-direction: column;
  94. align-items: center;
  95. justify-content: center;
  96. flex: 1;
  97. width: 750rpx;
  98. /* #endif */
  99. }
  100. .wave-text-box {
  101. /* #ifndef APP-NVUE */
  102. animation: text 1s ease-out infinite alternate;
  103. /* #endif */
  104. }
  105. .wave-text {
  106. font-weight: 700;
  107. }
  108. .wave-pallet {
  109. position: absolute;
  110. bottom: 0;
  111. left: 0;
  112. right: 0;
  113. height: 20rpx;
  114. background-color: rgba(207, 206, 207, 0.45);
  115. border-radius: 50%;
  116. /* #ifndef APP-NVUE */
  117. filter: blur(2px);
  118. animation: pallet 1s ease-out infinite alternate;
  119. /* #endif */
  120. }
  121. /* #ifndef APP-NVUE */
  122. @keyframes text {
  123. 0% {
  124. transform: translateY(0) scale(1.08, 0.98);
  125. }
  126. 100% {
  127. transform: translateY(-90%);
  128. }
  129. }
  130. @keyframes pallet {
  131. 0% {
  132. transform: scale(0.4);
  133. }
  134. 100% {
  135. transform: scale(1);
  136. }
  137. }
  138. /* #endif */
  139. </style>