PERSONAL CHRONICLE

The Book of Life

// ================================== // PAGE PHYSICS ENGINE // ================================== const activePage = rightPage; const position = activePage.geometry.attributes.position; const original = []; for(let i=0;i{ targetFlip=0; },1200); } // ================================== // MOUSE DRAG // ================================== window.addEventListener( "pointerdown", (e)=>{ dragging=true; startX=e.clientX; } ); window.addEventListener( "pointermove", (e)=>{ if(!dragging) return; let distance = e.clientX-startX; let amount = Math.max( 0, Math.min( 1, -distance/250 ) ); flipAmount=amount; } ); window.addEventListener( "pointerup", ()=>{ if(!dragging) return; dragging=false; if(flipAmount>.35){ targetFlip=1; } else{ targetFlip=0; } }); // ================================== // MOBILE SWIPE // ================================== let touchStart=0; window.addEventListener( "touchstart", (e)=>{ touchStart= e.touches[0].clientX; } ); window.addEventListener( "touchend", (e)=>{ let end= e.changedTouches[0].clientX; if(touchStart-end>80){ flipNext(); } } ); // ================================== // DESKTOP AUTO FLIP // ================================== setInterval(()=>{ if(innerWidth>700){ flipNext(); } },10000);