Back to library
INTERACTION_110

Image Distortion.

A subtle ripple runs through the image on hover. Undistorted before the trigger; raising displacement scale briefly then easing it back to 0 once hover.

CATEGORY
Images
COMPLEXITY
Advanced
TECH
CSS
PLATFORM
Desktop
PERFORMANCE
Heavy
LIVE PLAYGROUND
Media
CSS / CSS
/* Image Distortion — A subtle ripple runs through the image on hover. */
.image-distortion {
  --dur: 900ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --stagger: 60ms;
  will-change: transform, opacity;
}

.image-distortion > * {
  opacity: 0;
  transform: translateY(14px);
  animation: image-distortion-in var(--dur) var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* undistorted -> raising displacement scale briefly then easing it back to 0 */
@keyframes image-distortion-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .image-distortion > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
React / TSX
import { useEffect, useRef } from "react";

/** Image Distortion — trigger: hover */
export function ImageDistortion({ 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="image-distortion" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

Media
INTERACTION_109CSS + JS

Image Trail

Thumbnails trail the cursor and fade out behind it.

Images / MediumView
INTERACTION_111CSS + JS

Image To Fullscreen

A thumbnail expands to fill the viewport from its own position.

Images / LightView
Media
INTERACTION_114CSS + JS

Product Image Rotation

A frame sequence spins the product as the pointer drags.

Images / MediumView
INTERACTION_105CSS

Image Mask Reveal

The image uncovers behind a mask while it settles from a slow zoom.

Images / LightView