const targetEl =
document.querySelector('body.single-post .page_content_wrap') ||
document.querySelector('body.custom-background .page_content_wrap') ||
document.querySelector('body.single-sp_event .page_content_wrap') ||
document.querySelector('body.single-sp_team .page_content_wrap') ||
document.querySelector('body.single-sp_player .page_content_wrap') ||
document.querySelector('body.post-type-archive-sp_event .page_content_wrap') ||
document.querySelector('body.post-type-archive-sp_team .page_content_wrap') ||
document.querySelector('body.post-type-archive-sp_player .page_content_wrap') ||
document.querySelector('body.single-sp_calendar .page_content_wrap') ||
document.querySelector('body.post-type-archive-sp_calendar .page_content_wrap') ||
body;
// Parallax-Konfiguration
const speed = 0.30; // Typischer Bereich: 0.20–0.40
const getOffset = () => window.pageYOffset || document.documentElement.scrollTop || 0;
let ticking = false;
const update = () => {
const yOffset = -(getOffset() * speed);
// nur Y-Position verschieben
targetEl.style.backgroundPosition = `center ${yOffset}px`;
ticking = false;
};
const requestTick = () => {
if (!ticking) {
requestAnimationFrame(update);
ticking = true;
}
};
// Scroll-Events (passiv für Performance)
window.addEventListener('scroll', requestTick, { passive: true });
window.addEventListener('resize', requestTick, { passive: true });
// Initiale Position setzen
update();
console.log("💻 Parallax aktiviert auf Desktop/Tablet (Target:", targetEl, ")");
});