$(document).ready(function () { var controller = new ScrollMagic.Controller(); $('.iconbox,.news,.oneline-fiveitem-01,.levelbox,.bgbox,.userpic,.slogan,footer').each(function(index, el) { $(el).attr('id','scene_0'+index); new ScrollMagic.Scene({triggerElement: '#scene_0'+index ,offset: -220}) // trigger animation by adding a css class .setClassToggle('#scene_0'+index , "view") .addTo(controller); }); var n =0; // 首頁主廣告 var all = $("#slideshow .slide-item").length; if(all >= 1){ var vid = $("#slideshow .slide-item").eq(0).find('video').get(0); // console.log($("#slideshow .slide-item").find('video')); if($("#slideshow .slide-item").find('video').length != 0){ $("#slideshow").owlCarousel({ dots: false, items : 1, nav : false, navText : ['',''], }); vid.play(); vid.addEventListener('ended', function(){ // only functional if "loop" is removed vid.pause(); vidFade(); // autoplay(); setInterval(function(){ // console.log(n); if(n < all-1){ $("#slideshow").trigger('next.owl.carousel',[300]); n++; }else{ $("#slideshow").trigger('to.owl.carousel',[0,300]); n=0; } },5000); }); }else{ $("#slideshow").owlCarousel({ dots: false, loop : true, items : 1, nav : false, navText : ['',''], autoplay:true, autoplayTimeout:6000 }); } } function vidFade() { vid.classList.add("stopfade"); } function autoplay(){ var inall = $("#slideshow .slide-item").length; var now = $('#slideshow .active').index(); if(inall == now){ console.log(now); $("#slideshow").trigger('to.owl.carousel',[0,300]); setTimeout(autoplay,5000); }else{ console.log(now); $("#slideshow").trigger('next.owl.carousel',[300]); setTimeout(autoplay,5000); } } $("#slideshow").on('changed.owl.carousel', function(event) { var num = event.item.index; if($("#slideshow").find('video') && $("#slideshow").find('.owl-item').eq(num).find('video')){ } }) // 熱銷商品 $('.oneline-fiveitem-01 .wrapper').owlCarousel({ responsive:{ 0:{ items : 1 }, 481:{ items : 2 }, 661:{ items : 1 }, 1025:{ items : 2 } }, nav : false, navText : ['',''], dots: true, }); setTimeout(function(){ $('.oneline-fiveitem-01 .wrapper').fadeIn('slow',function(){ $(this).css({'opacity':1}); }); },1000) $('.picbox').on('change.owl.carousel',function(event){ var id = $(this).find('.active').eq(0).children('.pic-item').attr('did'); if(id==undefined){ id = $(this).find('.active').siblings('.owl-item').children('.pic-item').attr('did'); } ajax_topic_content(id); }); function ajax_topic_content(topic_id){ $.post('/module/ajax/ajax_get_topic_content-p.php', {ID :topic_id}, function(h){ $("#topic_content").html(h.Content); }, 'json'); } });