Remove background mouse pan effect

This commit is contained in:
2026-02-04 14:38:15 +01:00
parent f6341ac0af
commit bf1ceba156
3 changed files with 3 additions and 49 deletions

41
wwwroot/js/effects.js vendored
View File

@@ -1,43 +1,4 @@
import { toast } from "./dom.js";
import { t } from "./i18n.js";
// Background parallax ------------------------------------------------
export function setupBackgroundPan(config = {}) {
const root = document.documentElement;
const maxOffset = config.maxOffsetPx ?? 30;
const ease = config.ease ?? 0.08;
const scaleFactor = config.scaleFactor ?? 1.12;
if (scaleFactor) {
root.style.setProperty("--bg-scale", scaleFactor);
}
let targetX = 0;
let targetY = 0;
let currX = 0;
let currY = 0;
const setTarget = (x, y) => {
targetX = x;
targetY = y;
};
const step = () => {
currX += (targetX - currX) * ease;
currY += (targetY - currY) * ease;
root.style.setProperty("--bg-x", `${currX}px`);
root.style.setProperty("--bg-y", `${currY}px`);
requestAnimationFrame(step);
};
window.addEventListener("mousemove", (e) => {
const nx = (e.clientX / window.innerWidth - 0.5) * 2;
const ny = (e.clientY / window.innerHeight - 0.5) * 2;
setTarget(-nx * maxOffset, -ny * maxOffset);
});
window.addEventListener("mouseleave", () => setTarget(0, 0));
window.addEventListener("blur", () => setTarget(0, 0));
step();
}
// Effects & helpers --------------------------------------------------
// Screenshot hover ---------------------------------------------------
export function setupCardVisualHover(el, url) {