INTERACTION_104CSS
Comparison Card Transition
Two states swap inside the same card frame.
Cards / LightView
The card expands into a modal from its own position. The modal unmounted and the card in the grid before the trigger; animating the modal from the card's bounding rect to its final size once clicking the card.
/* Card To Modal Transition — The card expands into a modal from its own position. */
.card-to-modal-transition {
--dur: 520ms;
--ease: cubic-bezier(0.22, 1, 0.36, 1);
--stagger: 60ms;
will-change: transform, opacity;
}
.card-to-modal-transition > * {
opacity: 0;
transform: translateY(14px);
animation: card-to-modal-transition-in var(--dur) var(--ease) forwards;
animation-delay: calc(var(--i, 0) * var(--stagger));
}
/* the modal unmounted and the card in the grid -> animating the modal from the card's bounding rect to its final size */
@keyframes card-to-modal-transition-in {
to {
opacity: 1;
transform: none;
filter: none;
}
}
@media (prefers-reduced-motion: reduce) {
.card-to-modal-transition > * {
opacity: 1;
transform: none;
animation: none;
}
}import { useEffect, useRef } from "react";
/** Card To Modal Transition — trigger: clicking the card */
export function CardToModalTransition({ 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="card-to-modal-transition" data-state="out">
{children}
</div>
);
}Two states swap inside the same card frame.
A card grows in place to reveal its detail without a page change.
A soft reflection sweeps across the glass surface on hover.
The card content shifts subtly with pointer position.