SectionGallery.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <section class="bg-[#050f05] py-12 md:py-16 flex flex-col items-center gap-20 overflow-hidden">
  3. <h2 class="max-w-[1021px] text-[22px] md:text-[32px] lg:text-[45px] text-center font-semibold text-white leading-snug md:leading-13 px-4">
  4. O programa não entrega apenas informação,
  5. <span class="text-gradient">conecta empresários ao ambiente onde decisões e oportunidades são construídas.</span>
  6. </h2>
  7. <div class="flex flex-col items-center gap-10 w-full">
  8. <div class="flex gap-3 w-full justify-start lg:justify-center overflow-x-auto lg:overflow-visible px-4 md:px-6 lg:px-0">
  9. <button
  10. v-for="(img, i) in images"
  11. :key="i" @click="goTo(i)"
  12. :class="[
  13. 'w-[110px] md:w-[130px] lg:w-[152px] h-[70px] md:h-[80px] lg:h-[76px] overflow-hidden transition-all shrink-0',
  14. current === i ? 'ring-2 ring-[#E3FA6D] opacity-100' : 'opacity-60 hover:opacity-80'
  15. ]">
  16. <img v-if="img.src" :src="img.src" class="w-full h-full object-cover" />
  17. </button>
  18. </div>
  19. <div class="relative w-full h-[220px] md:h-[240px] lg:h-[280px] flex items-center justify-center px-4 md:px-6 lg:px-0">
  20. <div
  21. v-for="(img, i) in images"
  22. :key="i"
  23. :style="getCardStyle(i)"
  24. class="absolute overflow-hidden transition-all duration-500 ease-in-out origin-center"
  25. >
  26. <img v-if="img.src" :src="img.src" class="w-full h-full object-cover" />
  27. </div>
  28. </div>
  29. <div class="flex gap-10 mt-2">
  30. <button @click="prev"
  31. class="text-[#8DC63F] text-4xl hover:opacity-75 transition-opacity leading-none">‹</button>
  32. <button @click="next"
  33. class="text-[#8DC63F] text-4xl hover:opacity-75 transition-opacity leading-none">›</button>
  34. </div>
  35. </div>
  36. </section>
  37. </template>
  38. <script setup lang="ts">
  39. import { ref } from 'vue'
  40. const current = ref(0)
  41. const images: { src: string | null }[] = [
  42. { src: '/img/DSC09420.jpg' },
  43. { src: '/img/DSC09531.JPG' },
  44. { src: '/img/DSC09537.jpg' },
  45. { src: '/img/IMG_0725.jpg' },
  46. { src: '/img/IMG_0960.jpg' },
  47. { src: '/img/IMG_0982.jpg' },
  48. { src: '/img/IMG_1058.JPG' },
  49. { src: '/img/IMG_1878.jpg' },
  50. { src: '/img/imersao_1.jpg' },
  51. { src: '/img/imersao_3.jpeg' },
  52. { src: '/img/imersao_5.jpeg' },
  53. { src: '/img/imersao_6.jpeg' },
  54. { src: '/img/img2.jpeg' },
  55. { src: '/img/img3.jpeg' },
  56. ]
  57. const xMap = [0, 340, 640]
  58. const wMap = [350, 270, 270]
  59. const hMap = [280, 240, 240]
  60. const opMap = [1, 0.8, 0.5]
  61. const zMap = [10, 5, 1]
  62. function normalizedOffset(i: number) {
  63. const len = images.length
  64. let offset = (i - current.value + len) % len
  65. if (offset > len / 2) offset -= len
  66. return offset
  67. }
  68. function getCardStyle(i: number) {
  69. const offset = normalizedOffset(i)
  70. const abs = Math.abs(offset)
  71. if (abs > 2) {
  72. const x = offset > 0 ? 650 : -650
  73. return {
  74. transform: `translateX(${x}px)`,
  75. width: '210px',
  76. height: '210px',
  77. opacity: '0',
  78. zIndex: '0',
  79. pointerEvents: 'none' as const,
  80. }
  81. }
  82. const x = offset < 0 ? -xMap[abs] : xMap[abs]
  83. const scale = window.innerWidth < 640 ? 0.75 : 1
  84. return {
  85. transform: `translateX(${x}px) scale(${scale})`,
  86. width: `${wMap[abs]}px`,
  87. height: `${hMap[abs]}px`,
  88. opacity: String(opMap[abs]),
  89. zIndex: String(zMap[abs]),
  90. outline: abs === 0 ? '2px solid #8DC63F' : 'none',
  91. }
  92. }
  93. function prev() {
  94. current.value = (current.value - 1 + images.length) % images.length
  95. }
  96. function next() {
  97. current.value = (current.value + 1) % images.length
  98. }
  99. function goTo(i: number) {
  100. current.value = i
  101. }
  102. </script>