// source --> https://karneval.berlin/wp-content/themes/kdk-theme/build/blocks/editorial/view.js?ver=50a7af8457e4f9c26a7c 
!function(){"use strict";const e=document.querySelectorAll(".kdk-editorial__inner[data-reveal]");if(e.length){const a=window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,r=e=>{const t=a?0:parseInt(e.dataset.revealDelay||"0",10);setTimeout(()=>e.classList.add("kdk-revealed"),t)};if("IntersectionObserver"in window&&!a){const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&(r(e.target),o.unobserve(e.target))})},{threshold:0,rootMargin:"0px 0px -8% 0px"});e.forEach(e=>o.observe(e)),setTimeout(()=>{e.forEach(e=>{e.classList.contains("kdk-revealed")||r(e)})},2e3)}else e.forEach(r)}const t=document.querySelectorAll(".kdk-editorial[data-parallax]");if(t.length){const i={slow:.06,medium:.12,fast:.2};let s=!1;function l(){t.forEach(e=>{const t=e.querySelector(".kdk-editorial__bg");if(!t)return;const n=i[e.dataset.parallax]||.08,a=e.getBoundingClientRect(),r=window.innerHeight,o=a.top+a.height/2-r/2;t.style.transform=`translateY(${o*n}px)`}),s=!1}window.addEventListener("scroll",()=>{s||(requestAnimationFrame(l),s=!0)},{passive:!0}),l()}const n=document.querySelectorAll('.kdk-editorial[data-cursor="magnetic"] .kdk-editorial__headline');n.length&&n.forEach(e=>{let t=0,n=0,a=0,r=0,o=null;function i(e,t,n){return e+(t-e)*n}function s(){a=i(a,t,.1),r=i(r,n,.1),e.style.transform=`translate(${a}px, ${r}px)`,Math.abs(a-t)>.1||Math.abs(r-n)>.1?o=requestAnimationFrame(s):(e.style.transform=`translate(${t}px, ${n}px)`,o=null)}e.closest(".kdk-editorial").addEventListener("mousemove",a=>{const r=e.getBoundingClientRect(),i=a.clientX-(r.left+r.width/2),l=a.clientY-(r.top+r.height/2);t=.18*i,n=.18*l,o||(o=requestAnimationFrame(s))}),e.closest(".kdk-editorial").addEventListener("mouseleave",()=>{t=0,n=0,o||(o=requestAnimationFrame(s))})})}();