vear-carousel.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <swiper class="image-container" previous-margin="100rpx" next-margin="100rpx" circular :autoplay="false" @change="swiperChange">
  3. <swiper-item :class="currentIndex == index ? 'swiper-item' : 'swiper-item-side'" v-for="(item, index) in imgList" :key="item[urlKey]">
  4. <image @click="clickImg(item)" :class="currentIndex == index ? 'item-img' : 'item-img-side'" :src="item[urlKey]" lazy-load :style="dontFirstAnimation ? 'animation: none;' : ''" mode="aspectFill"></image>
  5. </swiper-item>
  6. </swiper>
  7. </template>
  8. <script>
  9. export default {
  10. props: {
  11. imgList: {
  12. type: Array,
  13. default() {
  14. return []
  15. }
  16. },
  17. urlKey: {
  18. type: String,
  19. default() {
  20. return ''
  21. }
  22. },
  23. },
  24. data() {
  25. return {
  26. currentIndex: 0,
  27. dontFirstAnimation: true
  28. }
  29. },
  30. methods: {
  31. swiperChange(e) {
  32. console.log(e);
  33. this.dontFirstAnimation = false
  34. this.currentIndex = e.detail.current
  35. this.$emit('changeTicket', this.currentIndex)
  36. },
  37. clickImg(item) {
  38. this.$emit('selected', item, this.currentIndex)
  39. }
  40. }
  41. }
  42. </script>
  43. <style scoped>
  44. .image-container {
  45. width: 750rpx;
  46. height: 480rpx;
  47. }
  48. .item-img {
  49. width: 500rpx;
  50. height: 480rpx;
  51. animation: to-big .3s;
  52. }
  53. .swiper-item {
  54. width: 500rpx;
  55. height: 300rpx;
  56. display: flex;
  57. justify-content: center;
  58. align-items: center;
  59. }
  60. .item-img-side {
  61. width: 500rpx;
  62. height: 400rpx;
  63. animation: to-mini .3s;
  64. }
  65. .swiper-item-side {
  66. width: 500rpx;
  67. height: 400rpx;
  68. display: flex;
  69. justify-content: center;
  70. align-items: center;
  71. }
  72. @keyframes to-mini
  73. {
  74. from {
  75. height: 480rpx;
  76. }
  77. to {
  78. height: 400rpx;
  79. }
  80. }
  81. @keyframes to-big
  82. {
  83. from {
  84. height: 400rpx;
  85. }
  86. to {
  87. height: 480rpx;
  88. }
  89. }
  90. </style>