Orbit Gallery Code
Premium scroll-driven layout where orbiting abstract cards converge into a sleek horizontal timeline.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
"use client";
import { useGSAP } from "@gsap/react";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import Image from "next/image";
import { useRef } from "react";
gsap.registerPlugin(useGSAP, ScrollTrigger);
export default function ScrollOrbitGallery() {
const containerRef = useRef<HTMLDivElement>(null);
const scrollSectionRef = useRef<HTMLDivElement>(null);
const playheadRef = useRef<HTMLDivElement>(null);
useGSAP(
() => {
// 1. Initial State: Offset the cards relative to their final horizontal layout position
// They float at the 4 corners of the screen (partially off-screen and rotated)
gsap.set(".orbit-card-0", {
x: "-15vw",
y: "-35vh",
rotation: -18,
scale: 0.75,
});
gsap.set(".orbit-card-1", {
x: "52vw",
y: "-38vh",
rotation: 12,
scale: 0.75,
});
gsap.set(".orbit-card-2", {
x: "-42vw",
y: "38vh",
rotation: -12,
scale: 0.75,
});
gsap.set(".orbit-card-3", {
x: "15vw",
y: "35vh",
rotation: 18,
scale: 0.75,
});
// Hide playhead and timeline tracks initially
gsap.set(".playhead-line", { scaleY: 0, opacity: 0 });
gsap.set(".timeline-track", { scaleX: 0, opacity: 0 });
// Hide card images initially
gsap.set(".card-image", { opacity: 0, scale: 0.9 });
const scroller = containerRef.current?.closest("#main-scroller") || undefined;
// 2. Master timeline linked to vertical scroll pinning
const tl = gsap.timeline({
scrollTrigger: {
trigger: scrollSectionRef.current,
scroller: scroller,
pin: true,
scrub: 0.6,
start: "top top",
end: "+=3000", // Pinned scroll height
invalidateOnRefresh: true,
},
});
// Phase 1: Convergence (0.0s to 1.2s)
// Cards slide from offset corners into a unified flat horizontal timeline row
tl.to(
".orbit-card-0, .orbit-card-1, .orbit-card-2, .orbit-card-3",
{
x: 0,
y: 0,
rotation: 0,
scale: 1,
duration: 1.2,
ease: "power2.inOut",
},
0,
);
// Fade in timeline track guides (0.8s to 1.2s)
tl.to(
".timeline-track",
{
scaleX: 1,
opacity: 0.15,
duration: 0.4,
ease: "power2.out",
},
0.8,
);
// Phase 2: Playhead Activation & Sweep (1.2s to 3.5s)
// Laser playhead line extends and sweeps across the cards
tl.to(
".playhead-line",
{
scaleY: 1,
opacity: 1,
duration: 0.3,
ease: "back.out(1.5)",
},
1.2,
).to(
".playhead-line",
{
left: "95vw",
duration: 2.0,
ease: "none", // Linear sweep mapping
},
1.5,
);
// Dynamic Card Magnification & Image Reveal during Playhead Sweep
// Card 0 (crosses around 1.73s, active range: 1.55s to 2.05s)
tl.to(".orbit-card-0", { scale: 1.08, duration: 0.25 }, 1.55)
.to(
".orbit-card-0 .card-inner-box",
{
borderColor: "#f1b333",
boxShadow: "0 12px 36px rgba(241, 179, 51, 0.35)",
duration: 0.25,
},
"<",
)
.to(
".orbit-card-0 .card-image",
{ opacity: 1, scale: 1.15, rotation: 4, duration: 0.25 },
"<",
)
.to(".orbit-card-0", { scale: 1, duration: 0.25 }, 1.8)
.to(
".orbit-card-0 .card-inner-box",
{
borderColor: "#2a2a2a",
boxShadow: "6px 6px 0px #2a2a2a",
duration: 0.25,
},
"<",
)
.to(
".orbit-card-0 .card-image",
{ scale: 1, rotation: 0, duration: 0.25 },
"<",
);
// Card 1 (crosses around 2.24s, active range: 2.05s to 2.55s)
tl.to(".orbit-card-1", { scale: 1.08, duration: 0.25 }, 2.05)
.to(
".orbit-card-1 .card-inner-box",
{
borderColor: "#0c9367",
boxShadow: "0 12px 36px rgba(12, 147, 103, 0.35)",
duration: 0.25,
},
"<",
)
.to(
".orbit-card-1 .card-image",
{ opacity: 1, scale: 1.15, rotation: -4, duration: 0.25 },
"<",
)
.to(".orbit-card-1", { scale: 1, duration: 0.25 }, 2.3)
.to(
".orbit-card-1 .card-inner-box",
{
borderColor: "#2a2a2a",
boxShadow: "6px 6px 0px #2a2a2a",
duration: 0.25,
},
"<",
)
.to(
".orbit-card-1 .card-image",
{ scale: 1, rotation: 0, duration: 0.25 },
"<",
);
// Card 2 (crosses around 2.75s, active range: 2.55s to 3.05s)
tl.to(".orbit-card-2", { scale: 1.08, duration: 0.25 }, 2.55)
.to(
".orbit-card-2 .card-inner-box",
{
borderColor: "#8b5cf6",
boxShadow: "0 12px 36px rgba(139, 92, 246, 0.35)",
duration: 0.25,
},
"<",
)
.to(
".orbit-card-2 .card-image",
{ opacity: 1, scale: 1.15, rotation: 4, duration: 0.25 },
"<",
)
.to(".orbit-card-2", { scale: 1, duration: 0.25 }, 2.8)
.to(
".orbit-card-2 .card-inner-box",
{
borderColor: "#2a2a2a",
boxShadow: "6px 6px 0px #2a2a2a",
duration: 0.25,
},
"<",
)
.to(
".orbit-card-2 .card-image",
{ scale: 1, rotation: 0, duration: 0.25 },
"<",
);
// Card 3 (crosses around 3.26s, active range: 3.05s to 3.55s)
tl.to(".orbit-card-3", { scale: 1.08, duration: 0.25 }, 3.05)
.to(
".orbit-card-3 .card-inner-box",
{
borderColor: "#c53b3a",
boxShadow: "0 12px 36px rgba(197, 59, 58, 0.35)",
duration: 0.25,
},
"<",
)
.to(
".orbit-card-3 .card-image",
{ opacity: 1, scale: 1.15, rotation: -4, duration: 0.25 },
"<",
)
.to(".orbit-card-3", { scale: 1, duration: 0.25 }, 3.3)
.to(
".orbit-card-3 .card-inner-box",
{
borderColor: "#2a2a2a",
boxShadow: "6px 6px 0px #2a2a2a",
duration: 0.25,
},
"<",
)
.to(
".orbit-card-3 .card-image",
{ scale: 1, rotation: 0, duration: 0.25 },
"<",
);
// Phase 3: Exit Staggered Slide-out (3.5s to 4.5s)
tl.to(
".playhead-line",
{
scaleY: 0,
opacity: 0,
duration: 0.2,
},
3.5,
).to(
".timeline-cards-row",
{
xPercent: -150,
duration: 1.0,
ease: "power2.in",
},
3.6,
);
},
{ scope: containerRef },
);
return (
<div
className="relative min-h-screen bg-[#f2ece0] text-[#2a2a2a] overflow-x-hidden selection:bg-wtf-yellow selection:text-black"
ref={containerRef}
>
{/* Dot Grid Background Overlay */}
<div className="absolute inset-0 dot-grid pointer-events-none z-0" />
{/* Dashboard Back Link */}
<div className="fixed left-6 top-6 z-50">
<button
onClick={() =>
window.history.length > 1
? window.history.back()
: (window.location.href = "/")
}
className="brutalist-btn bg-wtf-yellow text-black px-4 py-2 text-xs font-mono font-bold uppercase rounded-md cursor-pointer border-2 border-[#2a2a2a] shadow-[3px_3px_0px_#2a2a2a]"
>
ā Back
</button>
</div>
{/* Scroll Indicator HUD */}
<div className="fixed bottom-6 left-1/2 -translate-x-1/2 z-40 font-mono text-xs uppercase tracking-widest text-[#2a2a2a]/60 animate-bounce pointer-events-none flex flex-col items-center gap-1">
<span>Scroll Down to Assemble</span>
<span className="text-wtf-orange font-bold text-sm">ā</span>
</div>
{/* Main Pinned Work Area */}
<div
ref={scrollSectionRef}
className="h-[calc(100vh-64px)] w-full flex items-center justify-center relative overflow-hidden"
>
{/* Timeline Track Line (Full Screen width) */}
<div className="timeline-track absolute left-[5vw] right-[5vw] h-[2px] bg-[#2a2a2a]/15 opacity-0 origin-left z-10" />
{/* Laser Playhead Line (Full Screen height) */}
<div
ref={playheadRef}
className="playhead-line absolute top-[5vh] bottom-[5vh] left-[5vw] w-[2px] bg-red-500 shadow-[0_0_20px_rgba(239,68,68,0.8)] z-30 origin-top transform -translate-x-1/2"
>
{/* Playhead Nodes */}
<div className="absolute -top-1 left-1/2 -translate-x-1/2 h-3.5 w-3.5 bg-red-500 border-2 border-white rounded-full animate-pulse shadow-[0_0_10px_rgba(239,68,68,1)]" />
<div className="absolute -bottom-1 left-1/2 -translate-x-1/2 h-3.5 w-3.5 bg-red-500 border-2 border-white rounded-full animate-pulse shadow-[0_0_10px_rgba(239,68,68,1)]" />
</div>
{/* Absolute Cards container */}
<div className="timeline-cards-row absolute inset-0 w-full h-full flex items-center justify-center pointer-events-none z-20">
<div className="relative w-full h-[280px] md:h-[360px] lg:h-[420px]">
{/* CARD 0: Golden Ratio Spiral (Gold) */}
<div className="orbit-card-0 absolute top-0 left-[4vw] md:left-[6vw] w-[20vw] md:w-[19vw] h-full transform will-change-transform pointer-events-auto">
<div className="card-inner-box w-full h-full border-3 border-[#2a2a2a] bg-white rounded-3xl flex flex-col justify-between p-5 md:p-6 shadow-[6px_6px_0px_#2a2a2a] transition-shadow duration-200">
<div className="flex justify-between items-center w-full font-mono text-[9px] text-zinc-400">
<span>MODULE_A // 01</span>
<span>[GOLDEN]</span>
</div>
<div className="flex-grow w-full flex items-center justify-center bg-[#fbfaf7] border border-zinc-200 my-3 rounded-2xl overflow-hidden relative">
{/* Tech Crosshair Placeholder in background */}
<div className="absolute inset-0 flex items-center justify-center pointer-events-none opacity-10">
<svg
className="w-8 h-8 text-[#2a2a2a]"
viewBox="0 0 100 100"
fill="none"
stroke="currentColor"
strokeWidth="2"
>
<line x1="50" y1="20" x2="50" y2="80" />
<line x1="20" y1="50" x2="80" y2="50" />
<circle cx="50" cy="50" r="10" />
</svg>
</div>
{/* Status indicator before reveal */}
<div className="absolute inset-0 flex flex-col items-center justify-center pointer-events-none z-0 p-4 text-center select-none">
<span className="font-mono text-[10px] uppercase tracking-widest text-[#2a2a2a]/45 font-bold animate-pulse">
[ LOCKED ]
</span>
<span className="font-mono text-[8px] uppercase tracking-wider text-[#2a2a2a]/30 mt-1">
Sweep to Scan
</span>
</div>
<div className="card-image absolute inset-0 w-full h-full z-10 pointer-events-none will-change-transform">
<Image
src="/demo.svg"
alt="Golden Spiral Preview"
fill
unoptimized
className="object-cover pointer-events-none"
/>
</div>
</div>
<div className="text-center">
<h3 className="font-serif font-black text-sm md:text-base text-[#2a2a2a] uppercase tracking-wider">
Golden Spiral
</h3>
<span className="font-mono text-[8px] text-zinc-400 uppercase">
Ratio Math
</span>
</div>
</div>
</div>
{/* CARD 1: Waveform Matrix (Green) */}
<div className="orbit-card-1 absolute top-0 left-[28vw] md:left-[29vw] w-[20vw] md:w-[19vw] h-full transform will-change-transform pointer-events-auto">
<div className="card-inner-box w-full h-full border-3 border-[#2a2a2a] bg-white rounded-3xl flex flex-col justify-between p-5 md:p-6 shadow-[6px_6px_0px_#2a2a2a] transition-shadow duration-200">
<div className="flex justify-between items-center w-full font-mono text-[9px] text-zinc-400">
<span>MODULE_B // 02</span>
<span>[WAVE]</span>
</div>
<div className="flex-grow w-full flex items-center justify-center bg-[#fbfaf7] border border-zinc-200 my-3 rounded-2xl overflow-hidden relative">
{/* Tech Crosshair Placeholder in background */}
<div className="absolute inset-0 flex items-center justify-center pointer-events-none opacity-10">
<svg
className="w-8 h-8 text-[#2a2a2a]"
viewBox="0 0 100 100"
fill="none"
stroke="currentColor"
strokeWidth="2"
>
<line x1="50" y1="20" x2="50" y2="80" />
<line x1="20" y1="50" x2="80" y2="50" />
<circle cx="50" cy="50" r="10" />
</svg>
</div>
{/* Status indicator before reveal */}
<div className="absolute inset-0 flex flex-col items-center justify-center pointer-events-none z-0 p-4 text-center select-none">
<span className="font-mono text-[10px] uppercase tracking-widest text-[#2a2a2a]/45 font-bold animate-pulse">
[ LOCKED ]
</span>
<span className="font-mono text-[8px] uppercase tracking-wider text-[#2a2a2a]/30 mt-1">
Sweep to Scan
</span>
</div>
<div className="card-image absolute inset-0 w-full h-full z-10 pointer-events-none will-change-transform">
<Image
src="/demo.svg"
alt="Waves Preview"
fill
unoptimized
className="object-cover pointer-events-none"
/>
</div>
</div>
<div className="text-center">
<h3 className="font-serif font-black text-sm md:text-base text-[#2a2a2a] uppercase tracking-wider">
Waves Osc
</h3>
<span className="font-mono text-[8px] text-zinc-400 uppercase">
Frequency
</span>
</div>
</div>
</div>
{/* CARD 2: Quantum Rings (Purple) */}
<div className="orbit-card-2 absolute top-0 left-[52vw] md:left-[52vw] w-[20vw] md:w-[19vw] h-full transform will-change-transform pointer-events-auto">
<div className="card-inner-box w-full h-full border-3 border-[#2a2a2a] bg-white rounded-3xl flex flex-col justify-between p-5 md:p-6 shadow-[6px_6px_0px_#2a2a2a] transition-shadow duration-200">
<div className="flex justify-between items-center w-full font-mono text-[9px] text-zinc-400">
<span>MODULE_C // 03</span>
<span>[RING]</span>
</div>
<div className="flex-grow w-full flex items-center justify-center bg-[#fbfaf7] border border-zinc-200 my-3 rounded-2xl overflow-hidden relative">
{/* Tech Crosshair Placeholder in background */}
<div className="absolute inset-0 flex items-center justify-center pointer-events-none opacity-10">
<svg
className="w-8 h-8 text-[#2a2a2a]"
viewBox="0 0 100 100"
fill="none"
stroke="currentColor"
strokeWidth="2"
>
<line x1="50" y1="20" x2="50" y2="80" />
<line x1="20" y1="50" x2="80" y2="50" />
<circle cx="50" cy="50" r="10" />
</svg>
</div>
{/* Status indicator before reveal */}
<div className="absolute inset-0 flex flex-col items-center justify-center pointer-events-none z-0 p-4 text-center select-none">
<span className="font-mono text-[10px] uppercase tracking-widest text-[#2a2a2a]/45 font-bold animate-pulse">
[ LOCKED ]
</span>
<span className="font-mono text-[8px] uppercase tracking-wider text-[#2a2a2a]/30 mt-1">
Sweep to Scan
</span>
</div>
<div className="card-image absolute inset-0 w-full h-full z-10 pointer-events-none will-change-transform">
<Image
src="/demo.svg"
alt="Quantum Ring Preview"
fill
unoptimized
className="object-cover pointer-events-none"
/>
</div>
</div>
<div className="text-center">
<h3 className="font-serif font-black text-sm md:text-base text-[#2a2a2a] uppercase tracking-wider">
Quantum Ring
</h3>
<span className="font-mono text-[8px] text-zinc-400 uppercase">
Resonance
</span>
</div>
</div>
</div>
{/* CARD 3: Isometric Grid (Red) */}
<div className="orbit-card-3 absolute top-0 left-[76vw] md:left-[75vw] w-[20vw] md:w-[19vw] h-full transform will-change-transform pointer-events-auto">
<div className="card-inner-box w-full h-full border-3 border-[#2a2a2a] bg-white rounded-3xl flex flex-col justify-between p-5 md:p-6 shadow-[6px_6px_0px_#2a2a2a] transition-shadow duration-200">
<div className="flex justify-between items-center w-full font-mono text-[9px] text-zinc-400">
<span>MODULE_D // 04</span>
<span>[MATRIX]</span>
</div>
<div className="flex-grow w-full flex items-center justify-center bg-[#fbfaf7] border border-zinc-200 my-3 rounded-2xl overflow-hidden relative">
{/* Tech Crosshair Placeholder in background */}
<div className="absolute inset-0 flex items-center justify-center pointer-events-none opacity-10">
<svg
className="w-8 h-8 text-[#2a2a2a]"
viewBox="0 0 100 100"
fill="none"
stroke="currentColor"
strokeWidth="2"
>
<line x1="50" y1="20" x2="50" y2="80" />
<line x1="20" y1="50" x2="80" y2="50" />
<circle cx="50" cy="50" r="10" />
</svg>
</div>
{/* Status indicator before reveal */}
<div className="absolute inset-0 flex flex-col items-center justify-center pointer-events-none z-0 p-4 text-center select-none">
<span className="font-mono text-[10px] uppercase tracking-widest text-[#2a2a2a]/45 font-bold animate-pulse">
[ LOCKED ]
</span>
<span className="font-mono text-[8px] uppercase tracking-wider text-[#2a2a2a]/30 mt-1">
Sweep to Scan
</span>
</div>
<div className="card-image absolute inset-0 w-full h-full z-10 pointer-events-none will-change-transform">
<Image
src="/demo.svg"
alt="Iso Matrix Preview"
fill
unoptimized
className="object-cover pointer-events-none"
/>
</div>
</div>
<div className="text-center">
<h3 className="font-serif font-black text-sm md:text-base text-[#2a2a2a] uppercase tracking-wider">
Iso Matrix
</h3>
<span className="font-mono text-[8px] text-zinc-400 uppercase">
Dimension
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
}
āļø Setup & Integration Guide
How to install, import, and configure this animation in your project
Option A: Install via CLI (Recommended)
You can install this component directly into your project via the TweenLabs CLI. It automatically creates the file and configures dependencies:
Option B: Manual Installation
Follow these steps to integrate the component into your project manually:
Install Packages
First, install GSAP and its official React hook helper library (@gsap/react).
Add Required CSS Styles
Copy the styles from the Required CSS tab above, or open the styles.css file that was automatically downloaded with your component. Paste these classes into your global stylesheet (e.g. src/app/globals.css or similar).
Create Component File
Create a new file in your React or Next.js project (e.g. src/components/OrbitGallery.tsx) and paste the code from the Standalone React Component tab above. If no standalone tab is available, copy the full page file code and adjust the routing logic for your needs.
ā ļø ScrollTrigger Plugin Notice
This component uses scroll-triggered timing events. Make sure to register the plugin as shown inside the code:
import { ScrollTrigger } from "gsap/ScrollTrigger";
gsap.registerPlugin(useGSAP, ScrollTrigger);Import & Render
Import and render the component in your page or view layout:
import OrbitGallery from "@/components/OrbitGallery";
export default function Page() {
return (
<main className="min-h-screen p-8 bg-[#f5f5f5] flex items-center justify-center">
<OrbitGallery />
</main>
);
}Customization & Component Properties
š ļø Customization & Component Properties (Props)
You can pass the following settings to configure the layout and animation details:
images(string[]): A list of absolute paths or URLs to render in the circular scrolling orbit.