Hilleagle<!-- ================= 完整的 CSS 样式区 ================= --> <style> /* ---- 基础重置 ---- */ .custom-product-block { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: #333; width: 100%; overflow: hidden; } .custom-product-block img { display: block; max-width: 100%; height: auto; border-radius: 12px; -webkit-user-drag: none; user-select: none; } .pd-text-center { text-align: center; margin-bottom: 15px; line-height: 1.6; font-size: 16px; color: #333; } /* ---- 1. Key Features 网格 ---- */ .key-features-section { margin: 30px 0; padding: 0 15px; } .kf-title { font-size: 32px; font-weight: bold; text-align: center; margin-bottom: 30px; color: #111; } .kf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; } .kf-card { position: relative; border-radius: 12px; overflow: hidden; display: block; aspect-ratio: 392 / 303; background: #f8f8f8; } .kf-text { position: absolute; top: 0; left: 0; padding: 24px; z-index: 10; } .kf-text h3 { font-size: 24px; font-weight: bold; margin: 0 0 8px 0; color: #111; text-shadow: 0px 1px 3px rgba(255,255,255,0.7); } .kf-text p { font-size: 14px; margin: 0; color: #333; font-weight: 500; text-shadow: 0px 1px 3px rgba(255,255,255,0.7); } .kf-img-box { width: 100%; height: 100%; position: relative; } .kf-img-box img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; } /* ---- 2. 原生 CSS 滑动通用容器 ---- */ .native-slider-container { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; gap: 24px; padding: 10px 15px; /* ★ 优化1:让吸附点考虑左右内边距,切换位置才精准 */ scroll-padding-left: 15px; scroll-padding-right: 15px; scrollbar-width: none; cursor: grab; } .native-slider-container::-webkit-scrollbar { display: none; } .native-slider-container:active { cursor: grabbing; } /* ★ 优化2:拖拽期间临时关闭吸附,避免拖动卡顿 */ .native-slider-container.is-dragging { scroll-snap-type: none; scroll-behavior: auto; } .slider-card { scroll-snap-align: start; display: flex; flex-direction: column; gap: 15px; } /* --- 105°/120°/140° 模块专属 --- */ .recline-section { background-color: #fff; margin-top: 50px; } .recline-header { text-align: center; padding: 0 15px; } .recline-header h3 { font-size: 24px; font-weight: bold; margin-bottom: 10px; color: #111; } .recline-header p { font-size: 16px; color: #333; margin-bottom: 20px; } .recline-outer-wrapper { position: relative; width: 100%; } .recline-slider .slider-card { flex: 0 0 100%; } .recline-img-box { width: 100%; aspect-ratio: 1660 / 720; border-radius: 12px; overflow: hidden; } .recline-img-box img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; } /* 图片悬浮左右箭头 (电脑端) */ .recline-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; background: #fff; border-radius: 50%; border: none; box-shadow: 0 4px 12px rgba(0,0,0,0.15); cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 10; transition: opacity 0.3s; } .recline-arrow:hover { opacity: 0.8; } /* ★ 优化3:首尾禁用状态 */ .recline-arrow.disabled { opacity: 0.3; pointer-events: none; } .recline-arrow-prev { left: 16px; } .recline-arrow-next { right: 16px; } /* ---- 胶囊切换器外壳 ---- */ .recline-tabs-outer { position: relative; max-width: 900px; margin: 10px auto 0; width: calc(100% - 30px); } .recline-tabs-wrapper { background-color: #2b2b2b; border-radius: 20px; padding: 6px; width: 100%; box-sizing: border-box; overflow: hidden; } .recline-tabs { display: flex; justify-content: space-between; gap: 4px; width: 100%; } .recline-tab { flex: 1; padding: 12px 10px; border-radius: 14px; cursor: pointer; background: transparent; color: #fff; transition: all 0.3s ease; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.3; border: 1px solid transparent; white-space: nowrap; user-select: none; } .recline-tab.active { background: #fff; color: #000; box-shadow: 0 2px 8px rgba(0,0,0,0.1); } .recline-tab .angle { font-size: 16px; font-weight: 600; display: block; } .recline-tab .desc { font-size: 14px; display: block; } /* 胶囊两侧滑动指示箭头 */ .tabs-arrow { display: none; position: absolute; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; background: #fff; border-radius: 50%; align-items: center; justify-content: center; z-index: 20; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.3); transition: opacity 0.2s; } .tabs-arrow.hide { opacity: 0; pointer-events: none; } .tabs-arrow-prev { left: 8px; } .tabs-arrow-next { right: 8px; } .tabs-arrow svg { width: 14px; height: 14px; stroke: #333; } /* --- Quality 模块专属 --- */ .my-quality-section { margin: 50px 0; width: 100%; } .my-quality-header { margin-bottom: 24px; text-align: left; padding: 0 15px; } .my-quality-header h2 { font-size: 32px; font-weight: bold; margin: 0 0 10px 0; color: #111; } .my-quality-header p { font-size: 16px; color: #555; margin: 0; } .quality-slider .slider-card { flex: 0 0 calc(50% - 12px); } .my-quality-img { width: 100%; aspect-ratio: 998 / 560; border-radius: 12px; overflow: hidden; background: #faf9f6; } .my-quality-img img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; } .my-quality-text h3 { font-size: 20px; font-weight: bold; margin: 0 0 8px 0; color: #111; } .my-quality-text p { font-size: 16px; color: #666; margin: 0; line-height: 1.5; } .my-quality-nav { display: flex; gap: 12px; margin-top: 10px; padding: 0 15px; } .my-btn { width: 44px; height: 44px; cursor: pointer; color: #333; transition: 0.2s; display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid #ddd; background: #fff; } .my-btn:hover { color: #000; background: #f0f0f0; } .my-btn svg { width: 24px; height: 24px; pointer-events: none; } .my-btn.disabled { opacity: 0.3; cursor: not-allowed; } /* ★ 优化4:键盘焦点样式(无障碍) */ .my-btn:focus-visible { outline: 2px solid #111; outline-offset: 2px; } /* ---- 3. 底部规格排版 ---- */ .pd-info-layout { display: flex; gap: 30px; margin-top: 30px; align-items: stretch; padding: 0 15px; } .pd-info-image { flex: 1; display: flex; align-items: center; justify-content: center; background: #f8f8f8; border-radius: 12px; padding: 10px; } .pd-info-text { flex: 1; display: flex; flex-direction: column; justify-content: center; } .pd-info-text p { text-align: left; margin-bottom: 16px; line-height: 1.6; font-size: 15px; color: #555; } .pd-info-text strong { color: #111; font-size: 16px; } /* ---- 4. 手机端适配 ---- */ @media (max-width: 768px) { .kf-title { font-size: 28px; } .kf-grid { grid-template-columns: 1fr; } .kf-card { display: flex; flex-direction: row; aspect-ratio: auto; } .kf-text { position: static; flex: 1; padding: 15px; display: flex; flex-direction: column; justify-content: flex-end; background: #f9f9f9; } .kf-text h3 { font-size: 16px; text-shadow: none; margin-bottom: 4px; } .kf-text p { font-size: 12px; text-shadow: none; } .kf-img-box { flex: 1; aspect-ratio: 178 / 173; height: auto; } .recline-img-box { aspect-ratio: auto; height: auto; } .recline-img-box img { height: auto; } .recline-slider { padding-bottom: 0; } .recline-arrow { display: none; } /* 手机端胶囊滑动优化 */ .recline-tabs-wrapper { overflow-x: auto; scrollbar-width: none; border-radius: 16px; -webkit-overflow-scrolling: touch; /* ★ 优化5:胶囊滚动也需考虑内边距 */ scroll-padding: 0 36px; } .recline-tabs-wrapper::-webkit-scrollbar { display: none; } .recline-tabs { min-width: max-content; padding: 0 36px; } .recline-tab { flex: none; padding: 10px 20px; } .recline-tab .angle { font-size: 15px; } .recline-tab .desc { font-size: 13px; } .tabs-arrow { display: flex; } .my-quality-header h2 { font-size: 26px; } .quality-slider .slider-card { flex: 0 0 85%; } .my-quality-img { aspect-ratio: 296 / 242; } .pd-info-layout { flex-direction: column; } .pd-info-image, .pd-info-text { width: 100%; } } </style> <!-- ================= 完整的 HTML 结构 ================= --> <div class="custom-product-block"> <!-- ====== 1. Key Features 网格 ====== --> <div class="key-features-section"> <div class="kf-title">Key Features at a Glance</div> <div class="kf-grid"> <div class="kf-card"> <div class="kf-text"> <h3>2D Headrest</h3> <p>Up / Down & Tilt</p> </div> <div class="kf-img-box"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/mobile-newheader.webp?v=1793256729"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/pc-newheader.jpg?v=1793256730" alt="2D Headrest" loading="lazy"></picture></div> </div> <div class="kf-card"> <div class="kf-text"> <h3>3D Armrest</h3> <p>Fully Adjustable</p> </div> <div class="kf-img-box"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/mobile-newfushou.webp?v=1793256729"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/pc-newfushou.jpg?v=1793256730" alt="3D Armrest" loading="lazy"></picture></div> </div> <div class="kf-card"> <div class="kf-text"> <h3>Ergonomic Lumbar Support</h3> <p>Up/Down Adjustable</p> </div> <div class="kf-img-box"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/mobile-newkb.jpg?v=1793256730"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/pc-newkaobei.jpg?v=1793256730" alt="Lumbar Support" loading="lazy"></picture></div> </div> <div class="kf-card"> <div class="kf-text"> <h3>Retractable Footrest</h3> <p>Your On-Demand Comfort</p> </div> <div class="kf-img-box"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/mobile-new-jiaota.jpg?v=1793256730"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/pc-newjiaota.jpg?v=1793256730" alt="Retractable Footrest" loading="lazy"></picture></div> </div> <div class="kf-card"> <div class="kf-text"> <h3>SGS Class-4</h3> <p>Certified Safety</p> </div> <div class="kf-img-box"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/mobile-CGS-4.jpg?v=1793239308"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/PC-SGS4.jpg?v=1793239309" alt="SGS Class-4" loading="lazy"></picture></div> </div> <div class="kf-card"> <div class="kf-text"> <h3>140° Recline</h3> <p>Zero-Gravity Nap</p> </div> <div class="kf-img-box"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/mobile-140.jpg?v=1793239308"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/PC-140.jpg?v=1793239309" alt="140 Degree Recline" loading="lazy"></picture></div> </div> </div> </div> <!-- ====== 2. Personal Comfort 轮播模块 ====== --> <div class="recline-section"> <div class="recline-header"> <h3>Personal Comfort, Your Way</h3> <p><strong>LEAN BACK. RESET. RECHARGE.</strong><br>140° Recline for Total Relaxation</p> </div> <div class="recline-outer-wrapper"> <div class="native-slider-container recline-slider" id="recline-scroll-area" role="region" aria-label="Recline angle carousel"> <div class="slider-card"> <div class="recline-img-box"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/90-mobile_1.webp?v=1793328166"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/PC-1_1.webp?v=1793328166" alt="105 degree recline" loading="lazy"></picture></div> </div> <div class="slider-card"> <div class="recline-img-box"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/115-125-mobile_1.webp?v=1793328166"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/pc-2_1.webp?v=1793328166" alt="120 degree recline" loading="lazy"></picture></div> </div> <div class="slider-card"> <div class="recline-img-box"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/140-mobile_1.webp?v=1793328166"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/PC-3_1.webp?v=1793328166" alt="140 degree recline" loading="lazy"></picture></div> </div> </div> <button class="recline-arrow recline-arrow-prev" id="btn-prev-recline" aria-label="Previous slide"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15 18L9 12L15 6" stroke="#333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg></button> <button class="recline-arrow recline-arrow-next" id="btn-next-recline" aria-label="Next slide"><svg width="24" height="24" viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 18L15 12L9 6" stroke="#333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg></button> </div> <div class="recline-tabs-outer"> <div class="tabs-arrow tabs-arrow-prev hide" id="tabs-prev" role="button" tabindex="0" aria-label="Scroll tabs left"><svg viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15 18L9 12L15 6" stroke="#333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg></div> <div class="recline-tabs-wrapper" id="recline-tabs-wrapper"> <div class="recline-tabs" id="recline-tabs" role="tablist"> <div class="recline-tab active" data-index="0" role="tab" aria-selected="true"> <span class="angle">105°</span><span class="desc">Relaxed Productivity</span> </div> <div class="recline-tab" data-index="1" role="tab" aria-selected="false"> <span class="angle">120°</span><span class="desc">Immersive Entertainment</span> </div> <div class="recline-tab" data-index="2" role="tab" aria-selected="false"> <span class="angle">140°</span><span class="desc">Zero-Gravity Nap</span> </div> </div> </div> <div class="tabs-arrow tabs-arrow-next" id="tabs-next" role="button" tabindex="0" aria-label="Scroll tabs right"><svg viewbox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 18L15 12L9 6" stroke="#333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg></div> </div> </div> <!-- ====== 3. Comfort That Lasts ====== --> <div style="margin-top: 50px; padding: 0 15px;"> <h3 class="pd-text-center" style="font-size: 24px; font-weight: bold; margin-bottom: 10px;">Comfort That Lasts</h3> <p class="pd-text-center">Breathable latex and high-density foam provide a plush feel and long-term support.</p> <picture> <source media="(max-width: 768px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/Comfort_That_Lasts.jpg?v=1793328167"> <img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/3_90a0e4b1-b944-4c8a-a893-40ec7bf87342.jpg?v=1788943018" alt="Comfort That Lasts" loading="lazy" style="width: 100%; height: auto; border-radius: 12px; display: block;"></picture> </div> <!-- ====== 4. Quality You Can Count On ====== --> <div class="my-quality-section"> <div class="my-quality-header"> <h2>QUALITY YOU CAN COUNT ON</h2> <p>Designed for dependable support and everyday use.</p> </div> <div class="native-slider-container quality-slider" id="quality-scroll-area" role="region" aria-label="Quality features carousel"> <div class="slider-card"> <div class="my-quality-img"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/Mobile-SGS.webp?v=1793265215"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/qigan-PC.webp?v=1793265215" alt="SGS Gas Lift" loading="lazy"></picture></div> <div class="my-quality-text"> <h3>SGS-Certified Class 4 Gas Lift</h3> <p>Reliable support and smooth height adjustment.</p> </div> </div> <div class="slider-card"> <div class="my-quality-img"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/Mobile-E6-Wheel.webp?v=1793265215"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/lunzi-PC.webp?v=1793265215" alt="Quiet Casters" loading="lazy"></picture></div> <div class="my-quality-text"> <h3>Smooth-Rolling, Quiet Casters</h3> <p>Designed for smooth, quiet movement to help maintain a distraction-free workspace.</p> </div> </div> <div class="slider-card"> <div class="my-quality-img"><picture><source media="(max-width: 749px)" srcset="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/Mobile-Feet.webp?v=1793265215"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/DIzuo-PC.webp?v=1793265215" alt="Steel Base" loading="lazy"></picture></div> <div class="my-quality-text"> <h3>Heavy-Duty Steel Base</h3> <p>A sturdy five-star steel base provides reliable stability and lasting durability.</p> </div> </div> </div> <div class="my-quality-nav"> <div class="my-btn" id="btn-prev-quality" role="button" tabindex="0" aria-label="Previous slide"><svg viewbox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="24" cy="24" r="22.9" stroke="currentColor" stroke-width="2.2"></circle><path d="M27.125 17.75L21 23.875L27.125 30" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"></path></svg></div> <div class="my-btn" id="btn-next-quality" role="button" tabindex="0" aria-label="Next slide"><svg viewbox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="24" cy="24" r="22.9" stroke="currentColor" stroke-width="2.2"></circle><path d="M21 30L27.125 23.875L21 17.75" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"></path></svg></div> </div> </div> <!-- ====== 5. 产品参数 ====== --> <h3 class="pd-text-center" style="font-size: 24px; font-weight: bold; margin-bottom: 10px; margin-top: 50px;">Product Information</h3> <div class="pd-info-layout"> <div class="pd-info-image"><img src="https://cdn.shopify.com/s/files/1/0827/5886/1028/files/Product_Information-Grey.webp?v=1793253993" alt="Product Dimensions" loading="lazy"></div> <div class="pd-info-text"> <p><strong>Recommended User Range</strong><br><span>Height: 5'1" – 6'3" / 155 – 195 cm<br>Maximum Load: 330 lbs / 150 kg</span></p> <p><strong>Product Dimensions</strong><br><span>27"-29"D x 26"W x 46.1"-48.4"H</span></p> <p><strong>Materials</strong><br><span>Base: Steel<br>Seat Cushion: Air Micro-Perforated Breathable Mesh</span></p> <p><strong>Included components</strong><br><span>With Footrest</span></p> <p><strong>Assembly</strong><br><span>Your chair arrives mostly built. Simply attach the base, seat, and backrest.</span></p> <p><strong>Warranty</strong><br><span>5 years: Core Load-bearing Components (Base, Gas Lift, Casters)<br>3 years: Other Components (Mechanism, Arms, Backrest, etc.)</span></p> <div style="margin: 20px 0; text-align: left;"><a href="https://youtu.be/ShLYTYxIXVs" rel="noopener" style="display: inline-block; padding: 12px 24px; background-color: #111; color: #fff; text-decoration: none; border-radius: 5px; font-weight: bold;" target="_blank">▶ Watch Installation Video</a></div> </div> </div> </div> <!-- ================= JS:轮播 / 联动 / 拖拽 / 无障碍 ================= --> <script> (function () { 'use strict'; /* ---------- 通用工具 ---------- */ function getGap(el) { var s = getComputedStyle(el); return parseFloat(s.columnGap || s.gap) || 0; } function getStep(slider, firstCard) { return firstCard.getBoundingClientRect().width + getGap(slider); } function debounce(fn, wait) { var t; return function () { var args = arguments, ctx = this; clearTimeout(t); t = setTimeout(function () { fn.apply(ctx, args); }, wait); }; } function isMobile() { return window.innerWidth <= 768; } /* ---------- 1. Personal Comfort 轮播 ---------- */ var reclineSlider = document.getElementById('recline-scroll-area'); var reclineTabs = Array.prototype.slice.call(document.querySelectorAll('.recline-tab')); var reclinePrev = document.getElementById('btn-prev-recline'); var reclineNext = document.getElementById('btn-next-recline'); var reclineCards = reclineSlider ? Array.prototype.slice.call(reclineSlider.querySelectorAll('.slider-card')) : []; var currentRecline = 0; function updateReclineTabs(index) { currentRecline = index; reclineTabs.forEach(function (tab, i) { var isActive = i === index; tab.classList.toggle('active', isActive); tab.setAttribute('aria-selected', isActive ? 'true' : 'false'); }); } function updateReclineArrows() { if (!reclinePrev || !reclineNext) return; reclinePrev.classList.toggle('disabled', currentRecline <= 0); reclineNext.classList.toggle('disabled', currentRecline >= reclineCards.length - 1); } function goToRecline(index) { if (!reclineSlider || !reclineCards.length) return; index = Math.max(0, Math.min(index, reclineCards.length - 1)); var step = getStep(reclineSlider, reclineCards[0]); reclineSlider.scrollTo({ left: index * step, behavior: 'smooth' }); updateReclineTabs(index); updateReclineArrows(); } function handleReclineScroll() { if (!reclineSlider || !reclineCards.length) return; var step = getStep(reclineSlider, reclineCards[0]); if (step <= 0) return; var idx = Math.round(reclineSlider.scrollLeft / step); idx = Math.max(0, Math.min(idx, reclineCards.length - 1)); if (idx !== currentRecline) { updateReclineTabs(idx); updateReclineArrows(); } } if (reclineSlider) { reclineSlider.addEventListener('scroll', debounce(handleReclineScroll, 80), { passive: true }); if (reclinePrev) reclinePrev.addEventListener('click', function () { goToRecline(currentRecline - 1); }); if (reclineNext) reclineNext.addEventListener('click', function () { goToRecline(currentRecline + 1); }); reclineTabs.forEach(function (tab) { tab.addEventListener('click', function () { var idx = parseInt(tab.getAttribute('data-index'), 10) || 0; goToRecline(idx); ensureTabVisible(tab); }); tab.addEventListener('keydown', function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); tab.click(); } }); }); updateReclineArrows(); } /* ---------- 胶囊标签横向滚动箭头(手机端) ---------- */ var tabsWrapper = document.getElementById('recline-tabs-wrapper'); var tabsPrev = document.getElementById('tabs-prev'); var tabsNext = document.getElementById('tabs-next'); function updateTabsArrows() { if (!tabsWrapper || !tabsPrev || !tabsNext) return; if (!isMobile()) { tabsPrev.classList.add('hide'); tabsNext.classList.add('hide'); return; } var maxScroll = tabsWrapper.scrollWidth - tabsWrapper.clientWidth; if (maxScroll <= 1) { tabsPrev.classList.add('hide'); tabsNext.classList.add('hide'); return; } tabsPrev.classList.toggle('hide', tabsWrapper.scrollLeft <= 1); tabsNext.classList.toggle('hide', tabsWrapper.scrollLeft >= maxScroll - 1); } function ensureTabVisible(tab) { if (!tabsWrapper || !tab || !isMobile()) return; var tabRect = tab.getBoundingClientRect(); var wrapRect = tabsWrapper.getBoundingClientRect(); var pad = 36; if (tabRect.left < wrapRect.left + pad) { tabsWrapper.scrollBy({ left: tabRect.left - wrapRect.left - pad, behavior: 'smooth' }); } else if (tabRect.right > wrapRect.right - pad) { tabsWrapper.scrollBy({ left: tabRect.right - wrapRect.right + pad, behavior: 'smooth' }); } } if (tabsWrapper) { tabsWrapper.addEventListener('scroll', updateTabsArrows, { passive: true }); if (tabsPrev) { tabsPrev.addEventListener('click', function () { tabsWrapper.scrollBy({ left: -150, behavior: 'smooth' }); }); tabsPrev.addEventListener('keydown', function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); tabsPrev.click(); } }); } if (tabsNext) { tabsNext.addEventListener('click', function () { tabsWrapper.scrollBy({ left: 150, behavior: 'smooth' }); }); tabsNext.addEventListener('keydown', function (e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); tabsNext.click(); } }); } updateTabsArrows(); } /* ---------- 2. Quality 轮播 ---------- */ var qualitySlider = document.getElementById('quality-scroll-area'); var qualityPrev = document.getElementById('btn-prev-quality'); var qualityNext = document.getElementById('btn-next-quality'); var qualityCards = qualitySlider ? Array.prototype.slice.call(qualitySlider.querySelectorAll('.slider-card')) : []; function updateQualityArrows() { if (!qualitySlider || !qualityPrev || !qualityNext) return; var maxScroll = qualitySlider.scrollWidth - qualitySlider.clientWidth; qualityPrev.classList.toggle('disabled', qualitySlider.scrollLeft <= 1); qualityNext.classList.toggle('disabled', qualitySlider.scrollLeft >= maxScroll - 1); } function scrollQualityBy(dir) { if (!qualitySlider || !qualityCards.length) return; var step = getStep(qualitySlider, qualityCards[0]); qualitySlider.scrollBy({ left: dir * step, behavior: 'smooth' }); } if (qualitySlider) { qualitySlider.addEventListener('scroll', updateQualityArrows, { passive: true }); if (qualityPrev) { qualityPrev.addEventListener('click', function () { if (!qualityPrev.classList.contains('disabled')) scrollQualityBy(-1); }); qualityPrev.addEventListener('keydown', function (e) { if ((e.key === 'Enter' || e.key === ' ') && !qualityPrev.classList.contains('disabled')) { e.preventDefault(); scrollQualityBy(-1); } }); } if (qualityNext) { qualityNext.addEventListener('click', function () { if (!qualityNext.classList.contains('disabled')) scrollQualityBy(1); }); qualityNext.addEventListener('keydown', function (e) { if ((e.key === 'Enter' || e.key === ' ') && !qualityNext.classList.contains('disabled')) { e.preventDefault(); scrollQualityBy(1); } }); } updateQualityArrows(); } /* ---------- 3. 鼠标拖拽滚动(桌面端) ---------- */ function enableDragScroll(el) { if (!el) return; var isDown = false, startX = 0, startScrollLeft = 0, moved = false; el.addEventListener('pointerdown', function (e) { if (e.pointerType !== 'mouse' || e.button !== 0) return; isDown = true; moved = false; startX = e.clientX; startScrollLeft = el.scrollLeft; el.classList.add('is-dragging'); e.preventDefault(); }); window.addEventListener('pointermove', function (e) { if (!isDown) return; var dx = e.clientX - startX; if (!moved && Math.abs(dx) > 5) moved = true; if (moved) el.scrollLeft = startScrollLeft - dx; }); window.addEventListener('pointerup', function () { if (!isDown) return; isDown = false; el.classList.remove('is-dragging'); }); // ★ 拖拽结束后抑制一次 click el.addEventListener('click', function (e) { if (moved) { e.preventDefault(); e.stopPropagation(); moved = false; } }, true); } enableDragScroll(reclineSlider); enableDragScroll(qualitySlider); /* ---------- 4. 窗口尺寸变化时刷新状态 ---------- */ window.addEventListener('resize', debounce(function () { updateTabsArrows(); updateReclineArrows(); updateQualityArrows(); }, 150)); })(); </script>
No card required. No card accepted. Pure imagination.
Garvee