animation.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view>
  3. <cu-custom bgImage="https://image.weilanwl.com/color2.0/plugin/wdh2236.jpg" :isBack="true"><block slot="backText">返回</block>
  4. <block slot="content">微动画</block>
  5. </cu-custom>
  6. <view class="cu-bar bg-white">
  7. <view class="action">
  8. <text class="cuIcon-title text-orange"></text> 默认效果
  9. </view>
  10. </view>
  11. <view class="padding-sm">
  12. <view class="flex flex-wrap justify-around">
  13. <button class="cu-btn margin-sm basis-sm shadow" :class="['bg-' + item.color,animation==item.name?'animation-' +item.name :'']"
  14. @tap="Toggle" :data-class="item.name" v-for="(item,index) in list" :key="index">{{item.name}}</button>
  15. </view>
  16. </view>
  17. <view class="cu-bar bg-white">
  18. <view class="action">
  19. <text class="cuIcon-title text-orange"></text> 反向动画
  20. </view>
  21. </view>
  22. <view class="padding-sm">
  23. <view class="flex flex-wrap justify-around">
  24. <button class="cu-btn animation-reverse margin-sm basis-sm shadow" :class="['bg-' + item.color,animation==item.name+'s'?'animation-' +item.name:'']"
  25. @tap="Toggle" :data-class="item.name+'s'" v-for="(item,index) in list" :key="index">{{item.name}}</button>
  26. </view>
  27. </view>
  28. <view class="cu-bar bg-white">
  29. <view class="action">
  30. <text class="cuIcon-title text-orange"></text> 延迟执行
  31. </view>
  32. <view class="action">
  33. <button class="cu-btn bg-cyan shadow" @tap="ToggleDelay">开始执行</button>
  34. </view>
  35. </view>
  36. <view class="padding-sm">
  37. <view class="flex flex-wrap justify-around">
  38. <button class="margin-sm basis-sm shadow cu-btn" :class="['bg-' + item.color,toggleDelay?'animation-slide-bottom':'']"
  39. :style="[{animationDelay: (index + 1)*0.1 + 's'}]" v-for="(item,index) in list" :key="index">0.{{index+1}}s</button>
  40. </view>
  41. </view>
  42. <view class="cu-bar bg-white">
  43. <view class="action">
  44. <text class="cuIcon-title text-orange"></text> Gif动画
  45. </view>
  46. </view>
  47. <view class="margin radius bg-gradual-green shadow-blur">
  48. <image src="https://image.weilanwl.com/gif/wave.gif" mode="scaleToFill" class="gif-black response" style="height:100upx"></image>
  49. </view>
  50. <view class="margin flex">
  51. <view class="bg-black flex-sub margin-right radius shadow-lg">
  52. <image src="https://image.weilanwl.com/gif/loading-black.gif" mode="aspectFit" class="gif-black response" style="height:240upx"></image>
  53. </view>
  54. <view class="bg-white flex-sub radius shadow-lg">
  55. <image src="https://image.weilanwl.com/gif/loading-white.gif" mode="aspectFit" class="gif-white response" style="height:240upx"></image>
  56. </view>
  57. </view>
  58. <view class="margin flex">
  59. <view class="bg-gradual-blue flex-sub margin-right radius shadow-lg">
  60. <image src="https://image.weilanwl.com/gif/rhomb-black.gif" mode="aspectFit" class="gif-black response" style="height:240upx"></image>
  61. </view>
  62. <view class="bg-white flex-sub radius shadow-lg">
  63. <image src="https://image.weilanwl.com/gif/rhomb-white.gif" mode="aspectFit" class="gif-white response" style="height:240upx"></image>
  64. </view>
  65. </view>
  66. <view class="margin flex">
  67. <view class="bg-white flex-sub margin-right radius shadow-lg">
  68. <image src="https://image.weilanwl.com/gif/loading-1.gif" mode="aspectFit" class="gif-white response" style="height:240upx"></image>
  69. </view>
  70. <view class="bg-black flex-sub radius shadow-lg">
  71. <image src="https://image.weilanwl.com/gif/loading-2.gif" mode="aspectFit" class="gif-black response" style="height:240upx"></image>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. export default {
  78. data() {
  79. return {
  80. animation:'',
  81. list: [{
  82. name: 'fade',
  83. color: 'red'
  84. },
  85. {
  86. name: 'scale-up',
  87. color: 'orange'
  88. },
  89. {
  90. name: 'scale-down',
  91. color: 'olive'
  92. },
  93. {
  94. name: 'slide-top',
  95. color: 'green'
  96. }, {
  97. name: 'slide-bottom',
  98. color: 'cyan'
  99. },
  100. {
  101. name: 'slide-left',
  102. color: 'blue'
  103. },
  104. {
  105. name: 'slide-right',
  106. color: 'purple'
  107. },
  108. {
  109. name: 'shake',
  110. color: 'mauve'
  111. }
  112. ],
  113. toggleDelay: false
  114. };
  115. },
  116. methods: {
  117. Toggle(e) {
  118. var anmiaton = e.currentTarget.dataset.class;
  119. this.animation= anmiaton;
  120. setTimeout(()=>{
  121. this.animation= '';
  122. }, 1000)
  123. },
  124. ToggleDelay() {
  125. this.toggleDelay= true;
  126. setTimeout(()=>{
  127. this.toggleDelay= false
  128. }, 1000)
  129. }
  130. },
  131. }
  132. </script>
  133. <style>
  134. @import "/plugin/colorui/animation.css";
  135. image[class*="gif-"] {
  136. border-radius: 6upx;
  137. display: block;
  138. }
  139. </style>