// ¸ÞÀÎ ·Ñ¸µ À̹ÌÁö $(function() { var vCount = $("#mainSlider ul.imgList li").length; var vIndex = 0; var vTimer; var vInterval = 100000; // ÀÚµ¿À¸·Î ½½¶óÀ̵ù µÇ´Â ÁÖ±â (´ÜÀ§ : ms) var swipeOptions = { triggerOnTouchEnd: true, swipeStatus: swipeStatus, allowPageScroll: "vertical", threshold: 10 }; // ¸ÞÀÎ ·Ñ¸µÀ̹ÌÁö ½º¿ÍÀÌÇÁ ¼ÂÆà function swipeStatus(event, phase, direction, distance) { vWidth = $("#mainSlider ul.imgList li").width(); if (phase == "move" && (direction == "left" || direction == "right")) { var duration = 0; if (direction == "left") { clearInterval(vTimer); $("#mainSlider ul.imgList").stop(true,false).animate({left:-(vWidth*vIndex) - distance + 'px'}, duration); } else if (direction == "right") { clearInterval(vTimer); $("#mainSlider ul.imgList").stop(true,false).animate({left:-(vWidth*vIndex) + distance + 'px'}, duration); } } else if (phase == "cancel") { mainSlide(); } else if (phase == "end") { if (direction == "right") { if(vIndex===0) { mainClear(); vIndex = 0; mainSlide(); return false; } mainClear(); vIndex--; mainSlide(); } else if (direction == "left") { if(vIndex===vCount-1) { vIndex = vCount-1; mainClear(); mainSlide(); return false; } mainClear(); vIndex++; mainSlide(); } } } $("#mainSlider ul.imgList").swipe(swipeOptions); // ÃʱâÈ­ function mainInit() { var wSize = $(window).width(); $("#mainSlider ul.imgList li").css('width',wSize + 'px'); $("#mainSlider ul.imgList").css('left',-(wSize * vIndex) + 'px'); } // ÆäÀÌÁö³×ÀÌ¼Ç ÃʱâÈ­ function pagingInit() { var _li = "
  • "; for(i=0; i= vCount) { vIndex = 0; } $("#mainSlider ul.imgList").stop(true,false).animate({left:-(vWidth*vIndex) + 'px'}, 600, 'easeOutCubic'); pagingActive(); } // ¸ÞÀÎ ·Ñ¸µÀ̹ÌÁö ŸÀÌ¸Ó ÃʱâÈ­ function mainClear() { $("#mainSlider ul.imgList").stop(); clearInterval(vTimer); vTimer = setInterval(function() { vIndex++; mainSlide(); }, vInterval); } // ÀÌÀü¹öÆ° Ŭ¸¯ $("#mainSlider a.prev").click(function() { if(!$("#mainSlider ul.imgList").is(':animated')) { mainClear(); vIndex--; mainSlide(); } }); // ´ÙÀ½¹öÆ° Ŭ¸¯ $("#mainSlider a.next").click(function() { if(!$("#mainSlider ul.imgList").is(':animated')) { mainClear(); vIndex++; mainSlide(); } }); // ÆäÀÌÁö³×ÀÌ¼Ç »óÅ º¯°æ function pagingActive() { $("#mainSlider ul.pagination li").removeClass('active'); $("#mainSlider ul.pagination li").eq(vIndex).addClass('active'); } // ÆäÀÌÁö³×ÀÌ¼Ç Å¬¸¯½Ã $(document).on('click', '#mainSlider ul.pagination li', function() { var idx = $(this).index(); if(!$("#mainSlider ul.imgList").is(':animated')) { mainClear(); vIndex = idx; mainSlide(); } }); // ÀÚµ¿ ½½¶óÀ̵å ŸÀÌ¸Ó ¼³Á¤ vTimer = setInterval(function() { vIndex++; mainSlide(); }, vInterval); // ·Îµå½Ã ·Ñ¸µÀ̹ÌÁö ÃʱâÈ­ $(window).load(function() { mainInit(); pagingInit(); }); // È­¸é »çÀÌÁî Á¶Àý½Ã ·Ñ¸µÀ̹ÌÁö »çÀÌÁî, À§Ä¡ ¸ÂÃã $(window).resize(function() { mainInit(); }); });