// 商品大小格切換 ;(function($) { $('.switch-group').on('click', '.switch-item', function(e) { const targetClass = $(this).data('target') $(this).addClass('now').siblings('.switch-item').removeClass('now') $('#Main_Content').removeAttr('class').addClass('content items-list').addClass(targetClass) }) })($) // 快速導覽展開/縮合 ;(function($) { $(document).on("click", ".fixedbar-collapse, .fixedbar-closer, .fixedbar-switch", function(){ $(".brand-fixedbar").toggleClass("theme-close") }) })($) // 手機快速導覽同menu效果 ;(function($) { //手機移除 let clientClickFlag = false //螢幕寬度 function checkMobileWidth(){ if($(window).width() >= 1200){ return false }else{ return true } } var mobileFlag = checkMobileWidth() $(window).on("resize", function(){ mobileFlag = checkMobileWidth() $(window).trigger("mobileFlagChangeBrand") }) $(".brand-fixedbar").on("click", ".fixedbar-anchor", function(e){ if(mobileFlag){ let _this = $(this), target = _this.data("target") $(".fixedbar-anchor").removeClass("in-active") _this.addClass("in-active") clientClickFlag = true $("html, body").animate({ scrollTop: $("#" + target).offset().top - 110 }, 240) } }) //手機版 滾動到位同步更新 let brandScroll = throttleScroll(function(currentScroll){ let navbarBox = $(".brand-fixedbar"), navbar = $(".fixedbar-anchorbox"), topItem = null $('.target-box').each(function(){ if($(this)[0].getBoundingClientRect().top<= 0){ topItem = $(this) }else{ return false } }) if(topItem){ let childItem = $(".fixedbar-anchor[data-target=" + topItem.attr("id") + "]") if(!childItem.hasClass("in-active")){ //點擊產生的scroll不觸發 if(!clientClickFlag){ $(".fixedbar-anchor").removeClass("in-active") childItem.addClass("in-active") navbar.animate({ scrollLeft: childItem.offset().left + navbar.scrollLeft() - 10 }) }else{ clientClickFlag = false } } } }, 250, $(window)) function checkBrandScroll(){ if(mobileFlag){ brandScroll.init() }else{ brandScroll.destroy() } } //手機板時移除通用的定位class function anchorReset(){ if(mobileFlag){ $(".fixedbar-anchor").removeClass("anchor-btn") }else{ $(".fixedbar-anchor").addClass("anchor-btn") } } checkBrandScroll() anchorReset() $(window).on("mobileFlagChangeBrand", checkBrandScroll) $(window).on("mobileFlagChangeBrand", anchorReset) })($)