feat: add verified deterministic Anime v4 choreography

This commit is contained in:
jarvis-at-skic committed 2026-10-23 09:40:36 +00:00
1 parent 563aaf4757
commit 6854138486
19 files changed
+493 -28

No files matched your search

+35 -13
View File
@@ -1,22 +1,42 @@
(() => {
const {animate, createTimeline, stagger} = anime;
const {createTimeline, stagger} = anime;
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
const printMode = location.search.includes('print-pdf');
const seen = new Set(); let active = []; let motion = !reduced.matches;
const seen = new Set(), timelines = new Map(); let motion = !reduced.matches;
const motionButton = document.querySelector('#motion');
// Explicit paused instances: Reveal owns slide navigation; one clock owns motion.
// Targets are dedicated motion wrappers, not positioned/rotated diagram parts.
document.querySelectorAll('.slides>section').forEach(slide=>{
const targets=[...slide.querySelectorAll('[data-motion]')];
if(!targets.length)return;
const tl=createTimeline({autoplay:false,defaults:{duration:300,ease:'outCubic'}});
if(slide.id==='sequence') {
['observe','interpret','act'].forEach((label,i)=>{
tl.label(label,i*180).add(targets[i],{opacity:[0,1],translateY:[12,0]},label);
});
} else tl.add(targets,{opacity:[0,1],translateY:[12,0],delay:stagger(70),duration:400},0);
tl.seek(tl.duration);tl.pause();timelines.set(slide,tl);
});
const allowed=()=>motion&&!reduced.matches&&!printMode&&!Reveal.isOverview();
function settle() {
active.forEach(a => { a.complete(); }); active = [];
document.querySelectorAll('[data-motion]').forEach(e => {e.style.opacity='1';e.style.transform='none';});
timelines.forEach(tl=>{tl.pause();tl.seek(tl.duration);});
}
function replay() {
settle();const tl=timelines.get(Reveal.getCurrentSlide());
if(!tl||!allowed())return false;
tl.seek(0);tl.play();return true;
}
function seek(timeMs) {
if(!Number.isFinite(timeMs))throw new TypeError('seek requires finite milliseconds');
const tl=timelines.get(Reveal.getCurrentSlide());
if(!tl)return false;
tl.pause();tl.seek(allowed()?Math.max(0,Math.min(timeMs,tl.duration)):tl.duration);
return true;
}
function run() {
settle(); const slide=Reveal.getCurrentSlide();
if (!slide || seen.has(slide.id) || !motion || reduced.matches || printMode) return;
seen.add(slide.id); const targets=slide.querySelectorAll('[data-motion]');
if (!targets.length) return;
if(slide.id==='sequence') {
const tl=createTimeline({defaults:{duration:300,ease:'outCubic'}});
targets.forEach((e,i)=>tl.add(e,{opacity:[0,1],translateY:[12,0]},i*180));active.push(tl);
} else active.push(animate(targets,{opacity:[0,1],translateY:[12,0],delay:stagger(70),duration:400,ease:'outCubic'}));
settle();const slide=Reveal.getCurrentSlide();
if(!slide||seen.has(slide.id)||!allowed())return;
seen.add(slide.id);replay();
}
function motionLabel(){motionButton.textContent=motion&&!reduced.matches?'Motion on':'Motion off';motionButton.setAttribute('aria-pressed',String(motion&&!reduced.matches));}
motionButton.onclick=()=>{motion=!motion;settle();motionLabel();};
@@ -37,5 +57,7 @@
run(); window.deckReady=true;
});
Reveal.on('slidechanged',()=>{try{localStorage.setItem('presentation-html-demo-slide',String(Reveal.getIndices().h));}catch{}run();});
window.presentationQA={settle,reduced:()=>reduced.matches,active:()=>active.filter(a=>!a.completed).length};
Reveal.on('overviewshown',settle);
document.addEventListener('visibilitychange',()=>{if(document.hidden)settle();});
window.presentationQA={settle,seek,replay,reduced:()=>reduced.matches,active:()=>[...timelines.values()].filter(tl=>!tl.paused&&!tl.completed).length};
})();