double-cube.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view>
  3. <view class="spinner-inside" :style="{
  4. width: size+'px',
  5. height: size+'px'
  6. }">
  7. <view :style="{ backgroundColor:color,width:size-10+'px',height:size-10+'px'}" class="cube1"></view>
  8. <view :style="{ backgroundColor:color,width:size-10+'px',height:size-10+'px'}" class="cube2"></view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name: 'doubleCube',
  15. props: {
  16. color: String,
  17. size: Number
  18. }
  19. }
  20. </script>
  21. <style scoped>
  22. .spinner-inside {
  23. margin: 50% auto;
  24. position: relative;
  25. transform: translate(-50%, -50%);
  26. }
  27. .cube1, .cube2 {
  28. position: absolute;
  29. top: 0;
  30. left: 0;
  31. -webkit-animation: cubemove 1.8s infinite ease-in-out;
  32. animation: cubemove 1.8s infinite ease-in-out;
  33. }
  34. .cube2 {
  35. -webkit-animation-delay: -0.9s;
  36. animation-delay: -0.9s;
  37. }
  38. @-webkit-keyframes cubemove {
  39. 25% { -webkit-transform: translateX(42px) rotate(-90deg) scale(0.5) }
  40. 50% { -webkit-transform: translateX(42px) translateY(42px) rotate(-180deg) }
  41. 75% { -webkit-transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5) }
  42. 100% { -webkit-transform: rotate(-360deg) }
  43. }
  44. @keyframes cubemove {
  45. 25% {
  46. transform: translateX(42px) rotate(-90deg) scale(0.5);
  47. -webkit-transform: translateX(42px) rotate(-90deg) scale(0.5);
  48. } 50% {
  49. transform: translateX(42px) translateY(42px) rotate(-179deg);
  50. -webkit-transform: translateX(42px) translateY(42px) rotate(-179deg);
  51. } 50.1% {
  52. transform: translateX(42px) translateY(42px) rotate(-180deg);
  53. -webkit-transform: translateX(42px) translateY(42px) rotate(-180deg);
  54. } 75% {
  55. transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5);
  56. -webkit-transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5);
  57. } 100% {
  58. transform: rotate(-360deg);
  59. -webkit-transform: rotate(-360deg);
  60. }
  61. }
  62. </style>