You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.9 KiB

2 years ago
  1. <template>
  2. <section class="trending-destination-services xl:tw-max-w-full xl:tw-mx-auto">
  3. <div class="swiper-container trendingDestinationServices" ref="trendingDestinationServices">
  4. <div :class="['swiper-wrapper']">
  5. <div v-for="(theme, idx) in themes" :key="idx" @mouseover="hoverCardIdx = idx"
  6. :class="['swiper-slide tw-relative tw-h-[164px] tw-bg-cover tw-bg-no-repeat tw-rounded-[8px] tw-transition-all tw-duration-200 tw-ease-in-out md:tw-h-[224px]', hoverCardIdx == idx ? 'xl:tw-w-[28%]' : 'xl:tw-w-[16.8%]']"
  7. :style="{ 'background-image': 'url(' + theme.image + ')' }">
  8. <nuxt-link class="tw-block tw-w-full tw-h-full tw-text-white" :to="localePath(destinations[idx])">
  9. <div
  10. class="overlap tw-absolute tw-left-0 tw-bottom-0 tw-w-full tw-h-1/2 tw-bg-gradient-to-b tw-from-transparent tw-to-black tw-rounded-[8px]">
  11. </div>
  12. <div class="tw-absolute tw-bottom-[12px] tw-left-[12px] tw-text-white xl:t18">{{ theme.name }}</div>
  13. </nuxt-link>
  14. </div>
  15. </div>
  16. </div>
  17. </section>
  18. </template>
  19. <script>
  20. // taipei 7
  21. // tokyo 21
  22. // frankfurt 76
  23. // las vegas 57
  24. // ho chi min 31
  25. import Swiper from "swiper/bundle";
  26. export default {
  27. delimiters: ['${', '}'],
  28. components: {
  29. Swiper
  30. },
  31. props: {
  32. themes: {
  33. type: Array,
  34. },
  35. title: {
  36. type: String,
  37. },
  38. },
  39. created() {
  40. if (this.$props.themes.length > 5) {
  41. this.$props.themes = this.$props.themes.slice(0, 5);
  42. }
  43. },
  44. data() {
  45. return {
  46. hoverCardIdx: 0,
  47. slide: null,
  48. trendingDestinationServicesSwiper: null,
  49. destinations: [
  50. "/exhibition?city=7",
  51. "/exhibition?city=21",
  52. "/exhibition?city=76",
  53. "/exhibition?city=57",
  54. "/exhibition?city=31",
  55. ],
  56. };
  57. },
  58. mounted() {
  59. let vm = this;
  60. vm.$nextTick(function () {
  61. vm.trendingDestinationServicesSwiper = new Swiper(".swiper-container.trendingDestinationServices", {
  62. direction: "horizontal",
  63. initialSlide: 0,
  64. slidesPerView: 2.2,
  65. slidesPerGroup: 2,
  66. observer: true, //修改swiper自己或子元素时,自动初始化swiper
  67. observeParents: true, //修改swiper的父元素时,自动初始化swiper
  68. spaceBetween: 15,
  69. preloadImages: false,
  70. lazy: {
  71. loadPrevNext: true,
  72. loadOnTransitionStart: true,
  73. loadPrevNextAmount: 3,
  74. },
  75. breakpoints: {
  76. 768: {
  77. slidesPerView: 2.5,
  78. },
  79. 1366: {
  80. slidesPerView: 5,
  81. allowTouchMove: false,
  82. },
  83. },
  84. });
  85. });
  86. },
  87. };
  88. </script>
  89. <style lang="scss" scoped>
  90. .swiper-slide {
  91. background-position: 50%;
  92. }
  93. .card-text {
  94. position: absolute;
  95. bottom: 0%;
  96. left: 10%;
  97. }
  98. .span {
  99. transition: transform 0.2s;
  100. }
  101. .v-slide-group__wrapper {
  102. touch-action: auto !important;
  103. }
  104. </style>