cringe-studios.com/special/april-fools.js
2024-03-08 19:51:51 +01:00

33 lines
897 B
JavaScript

let websiteScale = 1;
let OVERRIDE_APRIL_FOOLS = false;
setInterval(() => {
const theTime = new Date();
if (!OVERRIDE_APRIL_FOOLS && (theTime.getDate() != 1 || theTime.getMonth() != 3)) {
document.body.style.transition = undefined;
document.body.style.transform = undefined;
return;
}
document.body.style.transition = "all linear 0.1s";
document.body.style.transform = "scale(" + websiteScale + ")";
websiteScale *= 0.95;
}, 100);
let oldMouseX, oldMouseY;
let oldMouseTime;
document.addEventListener("mousemove", (ev) => {
let time = new Date().getTime();
if(oldMouseX !== undefined || oldMouseY !== undefined) {
let dist = Math.sqrt(Math.pow(oldMouseX - ev.x, 2) + Math.pow(oldMouseY - ev.y, 2));
let velocity = dist / (time - oldMouseTime);
websiteScale = Math.min(1, websiteScale * 1 + velocity/750);
}
oldMouseX = ev.x;
oldMouseY = ev.y;
oldMouseTime = time;
})