Motion Kit

Interaction

Image Trail

An interactive effect that spawns a trail of images following the cursor with scaling and rotation.

  • lit
  • gsap

Preview

Move the pointer through the frame to emit an image trail with pooled GSAP animations.

Installation

pnpm dlx shadcn@latest add https://motion-kit-astro.vercel.app/r/image-trail.json

Usage

---
import "@/components/motion-kit/image-trail-element.ts";

const images = [
  "/images/trail-1.png",
  "/images/trail-2.png",
  "/images/trail-3.png"
];

const config = {
  imageLifespan: 600,
  removalTickMs: 16,
  mouseThreshold: 40,
  minMovementForImage: 5,
  inDuration: 600,
  outDuration: 800,
  maxRotationFactor: 3,
  baseRotation: 30,
  speedSmoothingFactor: 0.25,
  minImageSize: 80,
  maxImageSize: 120,
  staggerOut: 40
};
---

<motion-image-trail
  images={images}
  config={config}
  class="w-full h-[600px]"
/>

API Reference

Attribute Type Default
images Array of image URLs to cycle through in the trail. array []
config Configuration object with imageLifespan, removalTickMs, mouseThreshold, minMovementForImage, inDuration, outDuration, maxRotationFactor, baseRotation, speedSmoothingFactor, minImageSize, maxImageSize, and staggerOut options. object {}