/* 兜爸心选官网 · 轻交互(无依赖) */ (function () { document.documentElement.classList.add('js'); var nav = document.getElementById('nav'); var onScroll = function () { if (!nav) return; nav.classList.toggle('is-stuck', window.scrollY > 24); }; onScroll(); window.addEventListener('scroll', onScroll, { passive: true }); var items = document.querySelectorAll('[data-reveal]'); if ('IntersectionObserver' in window) { var io = new IntersectionObserver(function (entries) { entries.forEach(function (e) { if (e.isIntersecting) { e.target.classList.add('is-in'); io.unobserve(e.target); } }); }, { rootMargin: '0px 0px -12% 0px', threshold: 0.12 }); items.forEach(function (el) { io.observe(el); }); } else { items.forEach(function (el) { el.classList.add('is-in'); }); } // 同一时间只展开一个 FAQ var qas = document.querySelectorAll('.qa'); qas.forEach(function (d) { d.addEventListener('toggle', function () { if (!d.open) return; qas.forEach(function (o) { if (o !== d) o.open = false; }); }); }); // 首屏手机屏:6 张界面截图自动轮换(悬停暂停 / 切后台暂停 / 尊重"减少动效") (function () { var box = document.getElementById('heroSlides'); if (!box) return; var slides = Array.prototype.slice.call(box.querySelectorAll('.hs-slide')); if (slides.length < 2) return; var reduce = window.matchMedia('(prefers-reduced-motion: reduce)'); var idx = 0, timer = null, hover = false; function show(n) { slides[idx].classList.remove('is-on'); idx = (n + slides.length) % slides.length; slides[idx].classList.add('is-on'); } function stop() { if (timer) { clearInterval(timer); timer = null; } } function start() { stop(); if (reduce.matches) return; timer = setInterval(function () { if (hover || document.hidden) return; show(idx + 1); }, 4200); } box.addEventListener('mouseenter', function () { hover = true; }); box.addEventListener('mouseleave', function () { hover = false; }); document.addEventListener('visibilitychange', function () { if (!document.hidden) start(); }); if (reduce.addEventListener) reduce.addEventListener('change', start); start(); })(); // 外链统一安全属性 document.querySelectorAll('a[href^="http"]').forEach(function (a) { a.rel = 'noopener'; }); })();