var script = function() { var winW = $(window).outerWidth(); var $win = $(window); /* slick ---------------------------------------------------*/ if (winW > 768) { var swiper2 = new Swiper('.gallery-txt', { effect: 'slide', //滑動方式 grabCursor: false, centeredSlides: true, //置中 initialSlide: 0, //起始幻燈片 spaceBetween: 50, slidesPerView: 'auto', loopedSlides: '5', touchRatio: 0, loop: true, navigation: { nextEl: '.btn_next', prevEl: '.btn_prev', }, }); var swiper = new Swiper('.gallery-top', { effect: 'slide', //滑動方式 grabCursor: false, centeredSlides: true, //置中 initialSlide: 0, //起始幻燈片 spaceBetween: -500, slidesPerView: 'auto', loopedSlides: '5', touchRatio: 0, loop: true, navigation: { nextEl: '.btn_next', prevEl: '.btn_prev', }, }); } else { // 手機版 var swiper2 = new Swiper('.gallery-txt', { effect: 'slide', //滑動方式 grabCursor: false, centeredSlides: true, //置中 initialSlide: 0, //起始幻燈片 spaceBetween: 100, slidesPerView: 'auto', loopedSlides: '5', touchRatio: 0, loop: true, navigation: { nextEl: '.btn_next', prevEl: '.btn_prev', }, }); var swiper = new Swiper('.gallery-top', { effect: 'slide', //滑動方式 grabCursor: false, centeredSlides: true, //置中 initialSlide: 0, //起始幻燈片 slidesPerView: 'auto', loopedSlides: '5', touchRatio: 0, loop: true, navigation: { nextEl: '.btn_next', prevEl: '.btn_prev', }, }); } $('.btn_next').click(function() { $('.mainIframe').each(function() { this.contentWindow.postMessage('{"event": "command", "func": "stopVideo", "args": ""}', '*'); }); }); $('.btn_prev').click(function() { $('.mainIframe').each(function() { this.contentWindow.postMessage('{"event": "command", "func": "stopVideo", "args": ""}', '*'); }); }); /* resize ------------------------------------------------------------*/ var _resize = function() { winW = $win.outerWidth(); winH = $win.height(); docH = $(document).height(); _scroll = $(window).scrollTop(); } _resize(); var windowHeight = $(window).height(); // Resize Event $(window).resize(function() { if ($(window).width() != windowHeight) { windowHeight = $(window).width(); _resize(); } }); } $(function() { script(); });