/*count*/ $(window).scroll(function() { let scrollDistance = $(window).scrollTop() + $(window).height(); if (scrollDistance > 300) { $('.count-num').each(function() { let $this = $(this), countTo = $this.attr('data-count'); $({ countNum: $this.text()}).animate({ countNum: countTo }, { duration: 1000, easing:'linear', step: function() { $this.text(Math.floor(this.countNum)); }, complete: function() { $this.text(this.countNum); } }); }); } }); /*회사소개*/ const imageContainer = document.querySelector(".image-container"); const image = imageContainer.querySelector(".scrole_img"); const imageHeight = image.offsetHeight; if (window.innerWidth > 880) { window.addEventListener("scroll", () => { const scrollTop = window.scrollY; if (window.innerWidth <= 1280) { if (scrollTop > 2900 && scrollTop < 3900) { image.style.top = `${scrollTop - 2900}px`; } } else if (window.innerWidth <= 1920) { if (scrollTop > 3200 && scrollTop < 4100) { image.style.top = `${scrollTop - 3200}px`; } } else { if (scrollTop > 3700 && scrollTop < 4700) { image.style.top = `${scrollTop - 3700}px`; } } }); } /*제품소개*/ $(document).ready(function() { $(".change_href00").hover(function() { $(".change_img00").attr("src", $(this).data("src")); }); }); $(document).ready(function() { $(".change_href01").hover(function() { $(".change_img01").attr("src", $(this).data("src")); }); }); $(document).ready(function() { $(".change_href02").hover(function() { $(".change_img02").attr("src", $(this).data("src")); }); }); $(document).ready(function() { $(".change_href03").hover(function() { $(".change_img03").attr("src", $(this).data("src")); }); }); /*새로운 소식*/ $(document).ready(function() { let carouselList = $('.carousel1 ul'); let carouselLength = carouselList.children().length; let carouselWidth = $('.carousel1').width() / 3; let carouselHeight = $('.carousel1').height(); let currentPosition = 0; let interval; function adjustCarousel() { if ($(window).width() <= 1040) { carouselWidth = $('.carousel1').width(); $('.carousel1 ul li').width(carouselWidth); $('.carousel1 ul li').height(carouselHeight); $('.carousel1 ul').width(carouselWidth * carouselLength); } else { carouselWidth = $('.carousel1').width() / 3; $('.carousel1 ul li').width(carouselWidth); $('.carousel1 ul li').height(carouselHeight); $('.carousel1 ul').width(carouselWidth * carouselLength); } } function startCarousel() { interval = setInterval(function() { currentPosition -= carouselWidth; carouselList.animate({marginLeft: 0}, 500, function() { carouselList.children().first().appendTo(carouselList); carouselList.css({marginLeft: 0}); currentPosition = 0; }); }, 3000); } function stopCarousel() { clearInterval(interval); } $(window).resize(function() { adjustCarousel(); }); adjustCarousel(); startCarousel(); $('.carousel1 .prev').click(function() { carouselList.animate({marginLeft: 0}, 100, function() { carouselList.children().last().prependTo(carouselList); carouselList.css({marginLeft: 0}); }); }); $('.carousel1 .next').click(function() { carouselList.animate({marginLeft: 0}, 100, function() { carouselList.children().first().appendTo(carouselList); carouselList.css({marginLeft: 0}); }); }); $('.carousel1').hover( function() { stopCarousel(); }, function() { startCarousel(); } ); });