Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
6 lines (6 loc) · 1.6 KB
/
Copy pathscript.js
File metadata and controls
6 lines (6 loc) · 1.6 KB
1
2
3
4
5
6
const reduceMotion=matchMedia('(prefers-reduced-motion: reduce)').matches;
const items=document.querySelectorAll('.reveal');
if('IntersectionObserver'in window&&!reduceMotion){const observer=new IntersectionObserver(entries=>entries.forEach(entry=>{if(entry.isIntersecting){entry.target.classList.add('visible');observer.unobserve(entry.target)}}),{threshold:.1});items.forEach(item=>observer.observe(item))}else items.forEach(item=>item.classList.add('visible'));
const pad=n=>String(n).padStart(2,'0');function tick(){const d=new Date();document.querySelector('#clock').textContent=`${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())} UTC`}tick();setInterval(tick,1000);
document.querySelector('#year').textContent=new Date().getFullYear();document.querySelector('#requestId').textContent=Math.random().toString(16).slice(2,8).toUpperCase();
if(!reduceMotion&&matchMedia('(pointer:fine)').matches){const cursor=document.querySelector('.cursor');addEventListener('pointermove',e=>{cursor.style.transform=`translate(${e.clientX}px,${e.clientY}px)`},{passive:true});document.querySelectorAll('a').forEach(a=>{a.addEventListener('pointerenter',()=>cursor.classList.add('active'));a.addEventListener('pointerleave',()=>cursor.classList.remove('active'))});document.querySelectorAll('.tilt').forEach(card=>{card.addEventListener('pointermove',e=>{const r=card.getBoundingClientRect(),x=(e.clientX-r.left)/r.width-.5,y=(e.clientY-r.top)/r.height-.5;card.style.transform=`perspective(900px) rotateX(${-y*3}deg) rotateY(${x*3}deg) translateY(-4px)`});card.addEventListener('pointerleave',()=>card.style.transform='')})}