// ========================================================== // 單書頁、活動頁腳本 // ========================================================== ;(function($) { let footStep = '' const footerSlide = $(".footer-slide") function footSetting(amount) { if(footerSlide.data('owl.carousel')) { footerSlide.data('owl.carousel').destroy() } console.log(typeof(amount), amount) if(footerSlide.length && footerSlide.children().length > amount) { footerSlide.owlCarousel({ autoplay: true, autoplaySpeed: 1000, autoplayTimeout: 8000, dots: true, dotsSpeed: 1000, items: amount, margin: 10, nav: false, navSpeed: 1000, navText: ['',''], slideBy: 'page', }); } } $(window).on('resize', function(e) { if($(this).width() > 768 && footStep !== 'desktop') { footStep = 'desktop' footSetting(4) } else if($(this).width() <= 768 && footStep !== 'mobile') { footStep = 'mobile' footSetting(2) } }) $(window).trigger('resize') const owlSlide = $(".slidebox") if(owlSlide.length) { owlSlide.owlCarousel({ items : 1, nav: true, navText : ['',''], dots: false, autoplay:true, navSpeed:1000, autoplayTimeout:8000, autoplaySpeed:1000, dotsSpeed:1000, margin: 10, }); } })($) // ;(function($) { // const mainOffset = $('main').offset().top // $(window).on('scroll', function(e) { // const targetLimit = $(this).scrollTop() > mainOffset - $(this).height() / 2 + $('.share-float').height() / 2 // if(targetLimit) { // $('.share-float').addClass('in-show') // } else { // $('.share-float').removeClass('in-show') // } // }) // $(window).trigger('scroll') // })($) // ========================================================== // 開啟商品購買跳窗 // ========================================================== ;(function($) { function log(obj) { console.log(obj) } $('body').on('click', '.open-amount', function(e) { $(this).parents('.prodList-item').find('.amount-warpper').addClass('in-active') }) $('body').on('click', '.amount-warpper', function(e) { if(e.target === e.currentTarget || e.target === $(this).find('.closer')[0] || $(e.target).hasClass('btn')) { $(this).removeClass('in-active') } }) })($)