// ========================================================== // 社群分享按鈕功能 // ========================================================== ;(function($) { const target = $('.share-float') const wrapper = $('.editor-wrapper') const listHeight = target.height() const wrapperOffset = wrapper.offset().top - $('#wrapper').offset().top const wrapperHeight = wrapper.height() const fadeHeight = $('.banner-wrapper').offset().top + $('.banner-wrapper').height() / 2 - $('#wrapper').offset().top $('#wrapper').on('scroll', function(e) { const nowScroll = $(this).scrollTop() const wrapperLimit = wrapperHeight + wrapperOffset - $(window).height() if(nowScroll > wrapperLimit) { target.addClass('in-overflow').removeClass('in-fixed') } else if(nowScroll > wrapperOffset) { target.addClass('in-fixed').removeClass('in-overflow') } else { target.removeClass('in-fixed').removeClass('in-fixed') } if(nowScroll > fadeHeight) { target.fadeIn(500) } else { target.fadeOut(250) } }) $('#wrapper').trigger('scroll') })($) ;(function($) { let columnStep = '' $(window).on('resize', function(e) { // ========================================================== // 相關專欄區塊調整 // ========================================================== const columnSlide = $('.relate-column') if($(this).width() > 1024 && columnStep !== 'desktop') { columnStep = 'desktop' columnSlide.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } if($(ele).children().length > 4) { $(ele).owlCarousel({ items: 4, margin: 15, slideBy: 'page', nav: true, dots: false, }) } }); } else if($(this).width() <= 1024 && $(this).width() > 768 && columnStep !== 'tablet') { columnStep = 'tablet' columnSlide.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } if($(ele).children().length > 3) { $(ele).owlCarousel({ items: 3, margin: 10, slideBy: 'page', nav: true, dots: false, }) } }); } else if($(this).width() <= 768 && columnStep !== 'mobile') { columnStep = 'mobile' columnSlide.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } }); } }) $(window).trigger('resize') })($) // ========================================================== // 其他人也買了、瀏覽紀錄 // ========================================================== ;(function($) { let otherStep = '' const owlTarget = $('.other-content .slideBox') $(window).on('resize', function(e) { if($(this).width() > 1024 && otherStep !== 'desktop') { otherStep = 'desktop' owlTarget.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } if($(ele).children().length > 4) { $(ele).owlCarousel({ items: 4, margin: 35, slideBy: 'page', nav: true, dots: false, }) } }); } else if($(this).width() <= 1024 && $(this).width() > 768 && otherStep !== 'tablet') { otherStep = 'tablet' owlTarget.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } if($(ele).children().length > 3) { $(ele).owlCarousel({ items: 3, margin: 15, slideBy: 'page', nav: true, dots: false, }) } }); } else if($(this).width() <= 768 && otherStep !== 'mobile') { otherStep = 'mobile' owlTarget.each(function(i, ele) { if($(ele).data('owl.carousel')) { $(ele).data('owl.carousel').destroy() } }); } }) $('.other-tags').on('click', '.item > button', function(e) { const hashTarget = $(this).data('hash') $(this).parents('.item').addClass('in-active').siblings('.item').removeClass('in-active') $(hashTarget).addClass('in-active').siblings('.content-item').removeClass('in-active') }) $(window).trigger('resize') $('.other-tags .item:first-child > button').trigger('click') })($)