SectionGallery.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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/group.png' },
  43. { src: '/img/group.png' },
  44. { src: '/img/group.png' },
  45. { src: '/img/group.png' },
  46. { src: '/img/group.png' },
  47. { src: '/img/group.png' },
  48. { src: '/img/group.png' },
  49. { src: '/img/group.png' },
  50. ]
  51. const xMap = [0, 320, 570]
  52. const wMap = [350, 270, 210]
  53. const hMap = [280, 240, 210]
  54. const opMap = [1, 0.8, 0.5]
  55. const zMap = [10, 5, 1]
  56. function normalizedOffset(i: number) {
  57. const len = images.length
  58. let offset = (i - current.value + len) % len
  59. if (offset > len / 2) offset -= len
  60. return offset
  61. }
  62. function getCardStyle(i: number) {
  63. const offset = normalizedOffset(i)
  64. const abs = Math.abs(offset)
  65. if (abs > 2) {
  66. const x = offset > 0 ? 650 : -650
  67. return {
  68. transform: `translateX(${x}px)`,
  69. width: '210px',
  70. height: '210px',
  71. opacity: '0',
  72. zIndex: '0',
  73. pointerEvents: 'none' as const,
  74. }
  75. }
  76. const x = offset < 0 ? -xMap[abs] : xMap[abs]
  77. const scale = window.innerWidth < 640 ? 0.75 : 1
  78. return {
  79. transform: `translateX(${x}px) scale(${scale})`,
  80. width: `${wMap[abs]}px`,
  81. height: `${hMap[abs]}px`,
  82. opacity: String(opMap[abs]),
  83. zIndex: String(zMap[abs]),
  84. outline: abs === 0 ? '2px solid #8DC63F' : 'none',
  85. }
  86. }
  87. function prev() {
  88. current.value = (current.value - 1 + images.length) % images.length
  89. }
  90. function next() {
  91. current.value = (current.value + 1) % images.length
  92. }
  93. function goTo(i: number) {
  94. current.value = i
  95. }
  96. </script>