更新easysales

This commit is contained in:
2026-11-18 12:31:17 +08:00
parent baf188858f
commit d31f5a701c
+52 -30
View File
@@ -44,7 +44,7 @@ h1{font-size:clamp(34px,5vw,56px);line-height:1.14;letter-spacing:-.025em;font-w
.day-item b{display:block;font-size:15.5px;margin-top:7px}
.day-item span{display:block;font-size:13.5px;line-height:1.6;color:var(--ink2);margin-top:4px}
.sec{padding:60px 0;border-top:1px solid var(--line)}
.sec{padding:60px 0;border-top:1px solid var(--line);scroll-margin-top:70px}
.sec:first-of-type{border-top:0}
.sec-head{display:flex;gap:24px;align-items:flex-start;margin-bottom:30px}
.idx{font-family:var(--mono);font-size:12.5px;color:var(--mute);padding-top:10px;min-width:24px}
@@ -402,19 +402,60 @@ td .role.t{color:var(--teal);background:rgba(15,118,110,.08)}
const $=(s,r=document)=>r.querySelector(s);
const $$=(s,r=document)=>Array.from(r.querySelectorAll(s));
$$('.tab').forEach(b=>b.addEventListener('click',()=>{
const navEl=document.querySelector('nav');
const scrollRoot=()=>document.scrollingElement||document.documentElement;
const navH=()=>navEl?navEl.getBoundingClientRect().height:0;
const curY=()=>Math.max(window.pageYOffset||0,scrollRoot().scrollTop||0);
function forceScroll(y){
const html=document.documentElement,prev=html.style.scrollBehavior;
html.style.scrollBehavior='auto';
try{ window.scrollTo({top:y,left:0,behavior:'instant'}); }catch(e){}
window.scrollTo(0,y);scrollRoot().scrollTop=y;html.scrollTop=y;
if(document.body) document.body.scrollTop=y;
requestAnimationFrame(()=>{html.style.scrollBehavior=prev;});
}
function smoothScrollTo(y){
const start=curY();
if(Math.abs(start-y)<2) return;
try{ window.scrollTo({top:y,left:0,behavior:'smooth'}); }
catch(e){ forceScroll(y); return; }
const settle=()=>{
const now=curY();
if(Math.abs(now-y)>10&&Math.abs(now-start)<10) forceScroll(y);
};
setTimeout(settle,450);
setTimeout(settle,1100);
}
const tabs=$$('.tab');
const secs=$$('section.sec[id]');
tabs.forEach(b=>b.addEventListener('click',()=>{
const el=document.getElementById(b.dataset.t);
if(el) el.scrollIntoView({behavior:'smooth',block:'start'});
if(!el) return;
tabs.forEach(t=>t.classList.toggle('on',t===b));
smoothScrollTo(Math.max(0,Math.round(el.getBoundingClientRect().top+curY()-navH()-10)));
}));
const io=new IntersectionObserver(es=>{
es.forEach(e=>{
if(e.isIntersecting){
$$('.tab').forEach(t=>t.classList.toggle('on',t.dataset.t===e.target.id));
function syncActive(){
if(!secs.length) return;
const line=curY()+navH()+40;
let cur=secs[0].id;
secs.forEach(s=>{ if(s.offsetTop<=line) cur=s.id; });
const maxY=Math.max(0,document.documentElement.scrollHeight-window.innerHeight);
if(curY()>=maxY-4) cur=secs[secs.length-1].id;
tabs.forEach(t=>t.classList.toggle('on',t.dataset.t===cur));
}
});
},{rootMargin:'-40% 0px -55% 0px'});
$$('section.sec[id]').forEach(s=>io.observe(s));
let navTick=false;
window.addEventListener('scroll',()=>{
if(navTick) return;
navTick=true;
requestAnimationFrame(()=>{navTick=false;syncActive();});
},{passive:true});
window.addEventListener('resize',syncActive);
syncActive();
const toast=$('#toast');
let tid;
@@ -439,26 +480,7 @@ $$('.copy').forEach(btn=>btn.addEventListener('click',async()=>{
}
}));
const scrollRoot=()=>document.scrollingElement||document.documentElement;
function hardScrollTop(){
const html=document.documentElement,prev=html.style.scrollBehavior;
html.style.scrollBehavior='auto';
try{ window.scrollTo({top:0,left:0,behavior:'instant'}); }catch(e){}
window.scrollTo(0,0);scrollRoot().scrollTop=0;html.scrollTop=0;
if(document.body) document.body.scrollTop=0;
requestAnimationFrame(()=>{html.style.scrollBehavior=prev;});
}
function backToTop(){
const start=Math.max(window.pageYOffset||0,scrollRoot().scrollTop||0);
const top=document.getElementById('top');
if(top&&top.scrollIntoView) top.scrollIntoView({behavior:'smooth',block:'start'});
try{ window.scrollTo({top:0,left:0,behavior:'smooth'}); }
catch(e){ hardScrollTop(); }
setTimeout(()=>{
const now=Math.max(window.pageYOffset||0,scrollRoot().scrollTop||0);
if(start>60&&start-now<80) hardScrollTop();
},700);
}
function backToTop(){ smoothScrollTo(0); }
const toTopBtn=$('#totop');
if(toTopBtn) toTopBtn.addEventListener('click',backToTop);
</script>