// ========================================================== // blog 主選單開關 // ========================================================== ;(function($) { $('.blog-header').on('click', '.with-child > a', function(e) { e.preventDefault() $(this).parent('.with-child').toggleClass('in-active') .siblings('.with-child').removeClass('in-active') }) })($) // ========================================================== // 文章輪播 // ========================================================== ;(function($) { const owlObj = { dots: false, margin: 20, nav: true, navText: ['', ''], responsive: { 0: { items: 2, }, 576: { items: 3, }, 768: { items: 4, }, 1200: { items: 5, }, }, } $('.article-slide').owlCarousel(owlObj) let asideStep = '' $(window).on('resize', function(e) { e.preventDefault() if($(this).width() >= 992 && asideStep !== 'desktop') { asideStep = 'desktop' $('.article-list').each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } }) } else if($(this).width() < 992 && asideStep !== 'mobile') { asideStep = 'mobile' $('.article-list').owlCarousel(owlObj) } }).trigger('resize') })($)