$(function() { var mIdx = 0, tIdx = 0, aIdx = 0; var mCount = $("#main_visual ul.visualImg li").length; var tCount = $("#teamSwipe ul.team_list li").length; var aCount = $("#asideSwipe ul li").length; var mSize, tSize, aSize, mTimer; var mInterval = 15000; var swipeOptionsM = { triggerOnTouchEnd: true, swipeStatus: swipeStatusM, allowPageScroll: "vertical", threshold: 10 }; var swipeOptionsT = { triggerOnTouchEnd: true, swipeStatus: swipeStatusT, allowPageScroll: "vertical", threshold: 10 }; var swipeOptionsA = { triggerOnTouchEnd: true, swipeStatus: swipeStatusA, allowPageScroll: "vertical", threshold: 10 }; $("#main_visual ul.visualImg").swipe(swipeOptionsM); $("#teamSwipe ul.team_list").swipe(swipeOptionsT); $("#asideSwipe ul").swipe(swipeOptionsA); function swipeStatusM(event, phase, direction, distance) { mSize = $("#main_visual ul.visualImg li").width(); if (phase == "move" && (direction == "left" || direction == "right")) { var duration = 0; if (direction == "left") { clearInterval(mTimer); $("#main_visual ul.visualImg").stop(true,false).animate({left:-(mSize*mIdx) - distance + 'px'}, duration); } else if (direction == "right") { clearInterval(mTimer); $("#main_visual ul.visualImg").stop(true,false).animate({left:-(mSize*mIdx) + distance + 'px'}, duration); } } else if (phase == "cancel") { teamSwipe(); } else if (phase == "end") { if (direction == "right") { if(mIdx===0) { main_stop(); mIdx = 0; mainSwipe(); return false; } main_stop(); mIdx--; mainSwipe(); } else if (direction == "left") { if(mIdx===mCount-1) { mIdx = mCount-1; main_stop(); mainSwipe(); return false; } main_stop(); mIdx++; mainSwipe(); } } } function swipeStatusT(event, phase, direction, distance) { tSize = $("#teamSwipe ul.team_list li").width(); if (phase == "move" && (direction == "left" || direction == "right")) { var duration = 0; if (direction == "left") { $("#teamSwipe ul.team_list").stop(true,false).animate({left:-(tSize*tIdx) - distance + 'px'}, duration); } else if (direction == "right") { $("#teamSwipe ul.team_list").stop(true,false).animate({left:-(tSize*tIdx) + distance + 'px'}, duration); } } else if (phase == "cancel") { teamSwipe(); } else if (phase == "end") { if (direction == "right") { if(tIdx===0) { tIdx = 0; teamSwipe(); return false; } tIdx--; teamSwipe(); } else if (direction == "left") { if(tIdx===tCount-1) { tIdx = tCount-1; teamSwipe(); return false; } tIdx++; teamSwipe(); } } } function swipeStatusA(event, phase, direction, distance) { aSize = $("#asideSwipe ul li").width(); if (phase == "move" && (direction == "left" || direction == "right")) { var duration = 0; if (direction == "left") { $("#asideSwipe ul").stop(true,false).animate({left:-(aSize*aIdx) - distance + 'px'}, duration); } else if (direction == "right") { $("#asideSwipe ul").stop(true,false).animate({left:-(aSize*aIdx) + distance + 'px'}, duration); } } else if (phase == "cancel") { asideSwipe(); } else if (phase == "end") { if (direction == "right") { if(aIdx===0) { aIdx = 0; asideSwipe(); return false; } aIdx--; asideSwipe(); } else if (direction == "left") { if(aIdx===aCount-3) { aIdx = aCount-3; asideSwipe(); return false; } aIdx++; asideSwipe(); } } } function mainSwipe(easing) { mSize = $("#main_visual ul.visualImg li").width(); if(mIdx<0) { mIdx = mCount - 1; } else if(mIdx>=mCount) { mIdx = 0; } if(easing==='easing') { $("#main_visual ul.visualImg").stop(true,false).animate({left:-(mSize*mIdx) + 'px'}, 500, 'easeInCubic'); } else { $("#main_visual ul.visualImg").stop(true,false).animate({left:-(mSize*mIdx) + 'px'}, 400); } $("#main_visual ul.paging li").removeClass('active'); $("#main_visual ul.paging li").eq(mIdx).addClass('active'); } function main_stop() { $("#main_visual ul.visualImg").stop(); clearInterval(mTimer); mTimer = setInterval(function() { mIdx++; mainSwipe('easing'); }, mInterval); } mTimer = setInterval(function() { mIdx++; mainSwipe('easing'); }, mInterval); function paging_init() { var _li = "
  • "; for(i=0; i=tCount) { tIdx = 0; } if(easing==='easing') { $("#teamSwipe ul.team_list").stop(true,false).animate({left:-(tSize*tIdx) + 'px'}, 400, 'easeInCubic'); } else { $("#teamSwipe ul.team_list").stop(true,false).animate({left:-(tSize*tIdx) + 'px'}, 300); } } $("#teamSwipe .prev").click(function(e) { if(!$("#teamSwipe ul.team_list").is(':animated')) { e.preventDefault(); tIdx--; teamSwipe('easing'); } }); $("#teamSwipe .next").click(function(e) { if(!$("#teamSwipe ul.team_list").is(':animated')) { e.preventDefault(); tIdx++; teamSwipe('easing'); } }); function asideSwipe(easing) { var winSize = $(window).width(); aSize = $("#asideSwipe ul li").width(); if(winSize>1280) { if(aIdx<0) { aIdx = aCount - 3; } else if(aIdx>=aCount-2) { aIdx = 0; } } else if(winSize>767 && winSize<1281) { if(aIdx<0) { aIdx = aCount - 2; } else if(aIdx>=aCount - 1) { aIdx = 0; } } else { if(aIdx<0) { aIdx = aCount - 1; } else if(aIdx>=aCount) { aIdx = 0; } } if(easing==='easing') { $("#asideSwipe ul").stop(true,false).animate({left:-(aSize*aIdx) + 'px'}, 400, 'easeInCubic'); } else { $("#asideSwipe ul").stop(true,false).animate({left:-(aSize*aIdx) + 'px'}, 300); } } $("#asideSwipe .prev").click(function(e) { if(!$("#asideSwipe ul").is(':animated')) { e.preventDefault(); aIdx--; asideSwipe('easing'); } }); $("#asideSwipe .next").click(function(e) { if(!$("#asideSwipe ul").is(':animated')) { e.preventDefault(); aIdx++; asideSwipe('easing'); } }); function swipe_init() { var winSize = $(window).width(); aSize = $("#main_visual ul.visualImg li").width(); $("#main_visual ul.visualImg > li").css({width:winSize + 'px'}); $("#main_visual ul.visualImg").css({left:-(mSize*mIdx) + 'px'}); if(winSize > 1280) { $("#asideSwipe ul li").css({width:(winSize/3.5) + 'px'}); aSize = $("#asideSwipe ul li").width(); $("#asideSwipe ul").css({left:-(aSize*aIdx) + 'px'}); } else if(winSize > 640 && winSize < 1281) { $("#asideSwipe ul li").css({width:(winSize/2) + 'px'}); aSize = $("#asideSwipe ul li").width(); $("#asideSwipe ul").css({left:-(aSize*aIdx) + 'px'}); } else { $("#asideSwipe ul li").css({width:(winSize) + 'px'}); aSize = $("#asideSwipe ul li").width(); $("#asideSwipe ul").css({left:-(aSize*aIdx) + 'px'}); } if(winSize < 769) { var tw = $("#teamSwipe").parent('.inner').width(); var tcount = $("#teamSwipe .team_list li").length; var tsize = $("#teamSwipe .team_list li").width(); $("#teamSwipe .team_list").css({width:(tw*tcount+10) + 'px', left:-(tsize*tIdx) + 'px'}); $("#teamSwipe .team_list li").css({width:tw + 'px'}); } else { $("#teamSwipe .team_list").css({width:''}); $("#teamSwipe .team_list li").css({width:''}); } } $(function() { swipe_init(); paging_init(); }) $(window).resize(function() { swipe_init(); }); });