clickCircle.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="circle" v-if="circleShow == 1" :style="isCricle" :class="circleShow==1?ainimaChoose:''"></view>
  3. </template>
  4. <script>
  5. export default {
  6. name: 'clickCircle',
  7. data() {
  8. return {
  9. isReady:1,
  10. isCricle:'',
  11. circleShow:0,
  12. ainimaChoose:''
  13. };
  14. },
  15. created() {
  16. if(Math.random() >= 0.5) {
  17. this.ainimaChoose = 'animation0'
  18. } else{
  19. this.ainimaChoose = 'animation1'
  20. }
  21. },
  22. methods:{
  23. conClick(e){
  24. var isReady = this.isReady
  25. if (isReady === 1) {
  26. // #ifdef H5
  27. var isTop = Math.round(e.changedTouches[0].clientY) + 15 + 'px'
  28. var isLeft = Math.round(e.changedTouches[0].clientX) - 25 + 'px'
  29. // #endif
  30. // #ifndef H5
  31. var isTop = Math.round(e.changedTouches[0].clientY) - 25 + 'px'
  32. var isLeft = Math.round(e.changedTouches[0].clientX) - 25 + 'px'
  33. // #endif
  34. this.isCricle = `top:${isTop};left:${isLeft};`
  35. this.circleShow = 1
  36. this.isReady = 0
  37. var that = this
  38. setTimeout(() => {
  39. that.circleShow = 0
  40. that.isReady = 1
  41. }, 300)
  42. }
  43. }
  44. }
  45. }
  46. </script>
  47. <style lang="scss">
  48. .circle{
  49. width: 100upx;
  50. height: 100upx;
  51. border-radius: 100%;
  52. position: fixed;
  53. z-index: 999;
  54. }
  55. // 动画0
  56. .animation0::before, .animation0::after {
  57. position: absolute;
  58. content: '';
  59. display: block;
  60. width: 140%;
  61. height: 100%;
  62. left: -20%;
  63. z-index: -1000;
  64. transition: all ease-in-out 0.5s;
  65. background-repeat: no-repeat;
  66. }
  67. .animation0::before{
  68. display: none;
  69. top: -55%;
  70. background-image: radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, transparent 20%, #ff0081 20%, transparent 30%), radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, transparent 10%, #ff0081 15%, transparent 20%), radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, #ff0081 20%, transparent 20%);
  71. background-size: 10% 10%, 20% 20%, 15% 15%, 20% 20%, 18% 18%, 10% 10%, 15% 15%, 10% 10%, 18% 18%;
  72. }
  73. .animation0::after{
  74. display: none;
  75. bottom: -55%;
  76. background-image: radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, transparent 10%, #ff0081 15%, transparent 20%), radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, #ff0081 20%, transparent 20%), radial-gradient(circle, #ff0081 20%, transparent 20%);
  77. background-size: 15% 15%, 20% 20%, 18% 18%, 20% 20%, 15% 15%, 10% 10%, 20% 20%;
  78. }
  79. .animation0::before{
  80. display: block;
  81. animation: topBubbles ease-in-out 0.75s forwards;
  82. }
  83. .animation0::after{
  84. display: block;
  85. animation: bottomBubbles ease-in-out 0.75s forwards;
  86. }
  87. @keyframes topBubbles {
  88. 0% {
  89. background-position: 5% 90%, 10% 90%, 10% 90%, 15% 90%, 25% 90%, 25% 90%, 40% 90%, 55% 90%, 70% 90%;
  90. }
  91. 50% {
  92. background-position: 0% 80%, 0% 20%, 10% 40%, 20% 0%, 30% 30%, 22% 50%, 50% 50%, 65% 20%, 90% 30%;
  93. }
  94. 100% {
  95. background-position: 0% 70%, 0% 10%, 10% 30%, 20% -10%, 30% 20%, 22% 40%, 50% 40%, 65% 10%, 90% 20%;
  96. background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%;
  97. }
  98. }
  99. @keyframes bottomBubbles {
  100. 0% {
  101. background-position: 10% -10%, 30% 10%, 55% -10%, 70% -10%, 85% -10%, 70% -10%, 70% 0%;
  102. }
  103. 50% {
  104. background-position: 0% 80%, 20% 80%, 45% 60%, 60% 100%, 75% 70%, 95% 60%, 105% 0%;
  105. }
  106. 100% {
  107. background-position: 0% 90%, 20% 90%, 45% 70%, 60% 110%, 75% 80%, 95% 70%, 110% 10%;
  108. background-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%, 0% 0%;
  109. }
  110. }
  111. // 动画1
  112. .animation1{
  113. animation: shockwave 0.3s 0s linear;
  114. }
  115. @keyframes shockwave {
  116. 0% {
  117. transform: scale(1);
  118. box-shadow: 0 0 2px rgba(0, 0, 0, 0.15), inset 0 0 1px rgba(0, 0, 0, 0.15);
  119. }
  120. 95% {
  121. box-shadow: 0 0 50px rgba(0, 0, 0, 0), inset 0 0 30px rgba(0, 0, 0, 0);
  122. }
  123. 100% {
  124. transform: scale(2.25);
  125. }
  126. }
  127. </style>