$(document).ready(function(){ var lang = $("html").attr("lang"); jsSub(); }); /* ================================================================= script description : Sub slide date : 2016.08.08 revisions : ================================================================= */ function jsSub(){ if(!$("#vissual").hasClass("subV")) return false; var $zone = $(".title-zone"), $visual = $(".visual"); $visual.each(function(){ var $bg = $(".bg-img img", this).attr("src"); $(this).css({ "background": "url(" + $bg + ") no-repeat 50% 80%", "background-size": "cover" }); }) SubSlide(); } function SubSlide(){ var $visual = $(".visual-section"), $num = $(".btngroup-num"), $control = $(".btngroup"); var size = $visual.size(); var s = 1000, spd = 8000; // indicator make var _html = ""; for(var i=1;i<=$visual.size();i++){ if(i==1){ _html += "
  • "+i+"
  • "; }else{ _html += "
  • "+i+"
  • "; } } $num.html(_html); // move $(".visual-section").eq(0).addClass("view").siblings().hide(); var interval = setInterval(animation, spd); function animation(){ // var size = $visual.size(), var current = $(".on", $num).index(); if(current >= $visual.size() -1){ $visual.eq(current).removeClass("view").stop().fadeOut(s); $visual.eq(0).stop().fadeIn(s, function(){ $(this).addClass("view"); }); $num.find("li").eq(0).addClass("on").siblings().removeClass('on'); }else{ $visual.eq(current).removeClass("view").stop().fadeOut(s); $visual.eq(current+1).stop().fadeIn(s, function(){ $(this).addClass("view"); }); $num.find("li").eq(current+1).addClass("on").siblings().removeClass('on'); } } // control $control.find("button").on("click", function(){ var $parent = $(this).parents(".btn"); $parent.removeClass("on").siblings().addClass("on"); if($parent.hasClass("play")){ interval = setInterval(animation, spd); }else{ clearInterval(interval); } return false; }) // indicator $num.find("li").on("click", function(){ clearInterval(interval); var $this = $(this), current = $this.index(); $this.addClass("on").siblings().removeClass("on"); $(".visual-section.view").removeClass("view").stop().fadeOut(s); $visual.eq(current).stop().fadeIn(s, function(){ $(this).addClass("view"); if($(".btngroup .on").hasClass("stop")){ interval = setInterval(animation, spd); } }); }) }