INTERACTION_155CSS
3D Wireframe
A perspective wireframe plane recedes into the distance.
Background / MediumView
A technical grid bends gently around a moving focus point. An even undistorted grid before the trigger; scaling and offsetting the masked grid region around the focus point once in view, with the focus point drifting or following the pointer.
/* Grid Distortion — A technical grid bends gently around a moving focus point. */
.grid-distortion {
--dur: 10s;
--ease: ease-in-out;
--stagger: 60ms;
will-change: transform, opacity;
}
.grid-distortion > * {
opacity: 0;
transform: translateY(14px);
animation: grid-distortion-in var(--dur) var(--ease) forwards;
animation-delay: calc(var(--i, 0) * var(--stagger));
}
/* an even undistorted grid -> scaling and offsetting the masked grid region around the focus point */
@keyframes grid-distortion-in {
to {
opacity: 1;
transform: none;
filter: none;
}
}
@media (prefers-reduced-motion: reduce) {
.grid-distortion > * {
opacity: 1;
transform: none;
animation: none;
}
}import { useEffect, useRef } from "react";
/** Grid Distortion — trigger: in view, with the focus point drifting or following the pointer */
export function GridDistortion({ children }: { children: React.ReactNode }) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
const el = ref.current;
if (!el) return;
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
el.dataset["state"] = "in";
return;
}
const io = new IntersectionObserver(
([entry]) => {
if (entry?.isIntersecting) {
el.dataset["state"] = "in";
io.unobserve(el);
}
},
{ threshold: 0.2 },
);
io.observe(el);
return () => io.disconnect();
}, []);
return (
<div ref={ref} className="grid-distortion" data-state="out">
{children}
</div>
);
}A perspective wireframe plane recedes into the distance.