$(function(){ /*-----------------------------------------------------------------------------------------------*/ /**/ bodywidth(); $(window).resize(function(){ bodywidth(); }); var first = ( '00' + $(".plist img").length ).slice( -2 ); $("#mainCont").addClass("data"+first); $(".data"+first+" img[data-ID='p" +first +"'] ").addClass("actives"); $("li[data-ID='p" +first +"'] ").addClass("actives"); pid =$("#mainCont img[data-ID='p" + first +"'] ").data("id"); pname =$("#mainCont img[data-ID='p" + first +"'] ").data("name"); /* change = function(pid){ pname =$("#pbar li[data-ID='" + pid +"'] ").next().data("name"); if(!pname){ pname=$(".plist img:first-child").data("name"); } pid =$("#pbar li[data-ID='" + pid +"'] ").next().data("id"); if(!pid){ pid=$(".plist img:first-child").data("id"); } indexChange(pname,pid); setTimeout(change, 3000 ,pid); } setTimeout(change, 3000,pid); */ var indexTimer; function startTimer(){ indexTimer= setInterval(function(){ pname =$(".actives").next().data("name"); if(!pname){ pname=$(".plist li:first-child").data("name"); } $("#pbar li[data-ID='" + pid +"'] ").fadeOut(0).css({animationPlayState:"paused"}); pid =$("#pbar li[data-ID='" + pid +"'] ").next().data("id"); if(!pid){ pid=$(".plist li:first-child").data("id"); } $("#pbar li[data-ID='" + pid +"'] ").fadeIn(0).css({animationPlayState:"running"}); indexChange(pname,pid); },8000); } function stopTimer(){ clearInterval(indexTimer); } startTimer();/**/ $(".mainImage li:not(.actives)").fadeOut(0); $('.plist li').on({ 'mouseenter':function(){ pname =$(this).data("name"); pid =$(this).data("id"); stopTimer(); indexChange(pname,pid); $("#pbar li").fadeOut(0).css({animationPlayState:"paused"}); }, 'mouseleave':function(){ pid =$(this).data("id"); startTimer(); $("#pbar li[data-ID='" + pid +"'] ").fadeIn(0).css({animationPlayState:"running"}); } }); /*-----------------------------------------------------------------------------------------------*/ }); function indexChange(pname,pid){ $("li").removeClass("actives"); $("li[data-ID='" + pid +"']").addClass("actives"); $(".mainImage li").fadeOut(100); $(".mainImage li[data-ID='" + pid +"']").fadeIn(200,function(e){$(".mainImage li").stop(false, true);}); } function bodywidth(){ wsize = $(window).width(); hsize = $(window).height(); } $(window).load(function () { //全ての読み込みが完了したら実行 $("body").fadeTo("slow", 1); });