common.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. $(function(){
  2. $("header .header--bottom .header--contents").on("mouseenter", function(e){
  3. if(e.type == "mouseenter"){
  4. $("header, .header--menu--dim").addClass("actv");
  5. }
  6. });
  7. $(".header--line--banner--wrap .close--btn").on("click", function(){
  8. $(".header--line--banner--wrap").addClass("actv");
  9. $("main").addClass("actv");
  10. });
  11. $(".header--menu--dim, .header--top").on("mouseenter", function(e){
  12. if(e.type == "mouseenter"){
  13. $("header, .header--menu--dim").removeClass("actv");
  14. }
  15. })
  16. $("header").on("mouseleave", function(){
  17. $("header").removeClass("actv");
  18. });
  19. const swiper = new Swiper('.main--visual', {
  20. loop: true,
  21. // autoplay: {
  22. // delay: 5000,
  23. // disableOnInteraction: false,
  24. // },
  25. pagination: {
  26. el: '.main--visual--fraction',
  27. type: "fraction",
  28. formatFractionCurrent: function (number) {
  29. return number.toString().padStart(2, '0');
  30. },
  31. formatFractionTotal: function (number) {
  32. return number.toString().padStart(2, '0');
  33. }
  34. },
  35. navigation: {
  36. nextEl: ".prev--next--wrap .next--btn",
  37. prevEl: ".prev--next--wrap .prev--btn",
  38. },
  39. on: {
  40. slideChange: function () {
  41. // 동그라미 pagination 수동 업데이트
  42. const bullets = document.querySelectorAll('.main--visual--pagination .swiper-pagination-bullet');
  43. bullets.forEach((bullet, index) => {
  44. bullet.classList.remove('swiper-pagination-bullet-active');
  45. if (index === this.realIndex) {
  46. bullet.classList.add('swiper-pagination-bullet-active');
  47. }
  48. });
  49. // progress bar 업데이트
  50. const totalSlides = this.slides.length;
  51. const currentIndex = this.realIndex;
  52. const progressPercent = ((currentIndex + 1) / totalSlides) * 100;
  53. const progressBar = document.querySelector('.main--visual--progress .progress-bar');
  54. const progressText = document.querySelector('.main--visual--progress .progress-text');
  55. if (progressBar) {
  56. progressBar.style.background = `linear-gradient(to right, #fff ${progressPercent}%, rgba(255,255,255,0.3) ${progressPercent}%)`;
  57. }
  58. if (progressText) {
  59. progressText.textContent = `${(currentIndex + 1).toString().padStart(2, '0')}`;
  60. }
  61. },
  62. init: function () {
  63. // 초기 동그라미 pagination 생성
  64. const totalSlides = this.slides.length;
  65. const paginationContainer = document.querySelector('.main--visual--pagination');
  66. paginationContainer.innerHTML = '';
  67. for (let i = 0; i < totalSlides; i++) {
  68. const bullet = document.createElement('span');
  69. bullet.className = 'swiper-pagination-bullet';
  70. if (i === 0) bullet.classList.add('swiper-pagination-bullet-active');
  71. bullet.addEventListener('click', () => {
  72. this.slideToLoop(i);
  73. });
  74. paginationContainer.appendChild(bullet);
  75. }
  76. // 초기 progress bar 설정
  77. const progressBar = document.querySelector('.main--visual--progress .progress-bar');
  78. const progressText = document.querySelector('.main--visual--progress .progress-text');
  79. if (progressBar) {
  80. progressBar.style.background = `linear-gradient(to right, #fff 50%, rgba(255,255,255,0.3) 50%)`;
  81. }
  82. if (progressText) {
  83. progressText.textContent = `01`;
  84. }
  85. }
  86. }
  87. });
  88. const swiper2 = new Swiper('.prof--swiper.pc', {
  89. loop: true,
  90. slidesPerView: "auto",
  91. spaceBetween: 30,
  92. navigation: {
  93. nextEl: ".prof--swiper--action .btn--wrap .next--btn",
  94. prevEl: ".prof--swiper--action .btn--wrap .prev--btn",
  95. },
  96. });
  97. const swiper3 = new Swiper('.prof--swiper.mo', {
  98. loop: true,
  99. slidesPerView: 1,
  100. spaceBetween: 15,
  101. navigation: {
  102. nextEl: ".prof--swiper--action .btn--wrap .next--btn",
  103. prevEl: ".prof--swiper--action .btn--wrap .prev--btn",
  104. },
  105. });
  106. $(window).on("scroll", function(){
  107. if($(window).scrollTop() > 50){
  108. $(".top--btn").addClass("actv");
  109. }else{
  110. $(".top--btn").removeClass("actv");
  111. }
  112. })
  113. $(".top--btn").on("click",function(){
  114. $(window).scrollTop(0);
  115. });
  116. $(".gnb--wrap").on("mouseenter mouseleave", function(e){
  117. if(e.type == "mouseenter"){
  118. $(this).addClass("actv");
  119. $(".header--dim").addClass("actv");
  120. }else{
  121. $(this).removeClass("actv");
  122. $(".header--dim").removeClass("actv");
  123. }
  124. });
  125. });