npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gsap-react-marquee

v0.3.0

Published

A high-performance React marquee component powered by GSAP

Downloads

43

Readme

GSAP React Marquee

A high-performance React marquee component powered by GSAP animations with intelligent container detection and seamless looping.

Installation

npm install gsap-react-marquee
# or
yarn add gsap-react-marquee
# or
pnpm add gsap-react-marquee

Usage

import Marquee from "gsap-react-marquee";

function App() {
  return (
    <Marquee dir="left" speed={100} fill={true} spacing={16}>
      <div>Hello world</div>
    </Marquee>
  );
}

Features

  • Intelligent Container Detection: Automatically detects whether containers have fixed dimensions or adapt to content, preventing recursive expansion loops
  • Seamless Looping: Advanced duplicate calculation ensures smooth infinite scrolling without gaps
  • High Performance: Built with GSAP for optimal animation performance
  • Responsive Design: Adapts to different screen sizes and container dimensions
  • Multiple Directions: Support for horizontal (left/right) and vertical (up/down) scrolling with proper axis handling
  • Smart Gradient Overlays: Automatic gradient positioning based on marquee orientation
  • Interactive Controls: Optional draggable interface and scroll synchronization
  • TypeScript Support: Full type safety and IntelliSense support

Props

| Prop | Type | Default | Description | | --------------- | ------------------------------------- | -------- | ------------------------------------------------------------- | | children | ReactNode | – | Content to render inside the marquee | | className | string | – | Additional CSS classes for styling | | dir | "right" \| "left" \| "up" \| "down" | "left" | Direction of the marquee movement | | loop | number | -1 | Number of loops (-1 = infinite) | | paused | boolean | false | Whether the marquee animation should be paused | | delay | number | 0 | Delay before the animation starts (in seconds) | | speed | number | 100 | Speed of the marquee animation in px/s | | fill | boolean | false | Whether the marquee should continuously fill the space | | pauseOnHover | boolean | false | Pause the marquee when hovering | | gradient | boolean | false | Enable gradient overlay (auto-adapts to orientation) | | gradientColor | string | – | Color of the gradient if enabled | | spacing | number | 16 | Spacing between repeated elements in px | | draggable | boolean | false | Enable dragging to scroll manually | | scrollFollow | boolean | false | Sync marquee with page scroll direction | | scrollSpeed | number | 2.5 | Speed factor when syncing with page scroll (max: 4, min: 1.1) |

Advanced Features

Intelligent Container Detection

The component automatically detects container dimensions to prevent recursive expansion:

  • Fixed Width Containers: Uses container dimensions for optimal duplicate calculation
  • Auto-Width Containers: Falls back to viewport dimensions to prevent layout loops
  • Safety Limits: Maximum of 15 duplicates to prevent performance issues
  • Development Logging: Debug information in development mode

Seamless Looping Algorithm

Enhanced duplicate calculation ensures perfect infinite scrolling:

  • Smart Target Size: Intelligently determines the space to fill (width for horizontal, height for vertical)
  • Gap Prevention: Calculates exact duplicates needed to eliminate visual gaps
  • Performance Optimized: Minimal DOM elements for maximum performance

Orientation-Aware Animations

The marquee automatically adapts its animation system based on direction:

  • Horizontal (left/right): Uses xPercent for X-axis animations with flexDirection: row
  • Vertical (up/down): Uses yPercent for Y-axis animations with flexDirection: column
  • Smart Gradients: Gradient overlays automatically position themselves based on scroll direction
    • Horizontal: Side gradients (left and right edges)
    • Vertical: Top and bottom gradients

Interactive Features

  • Draggable Support: Drag to manually control the marquee position
  • Scroll Synchronization: Link marquee speed to page scroll direction
  • Pause on Hover: Temporarily stop animation when hovering
  • Inertia Scrolling: Smooth momentum-based scrolling when dragging (requires GSAP InertiaPlugin)

Examples

Basic Marquee

<Marquee dir="left" speed={50}>
  <span>Scrolling text goes here</span>
</Marquee>

Vertical Marquee with Gradient

<Marquee dir="up" speed={80} gradient={true} gradient>
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
</Marquee>

Interactive Draggable Marquee

<Marquee dir="right" speed={100} draggable={true} pauseOnHover={true}>
  <img src="image1.jpg" alt="1" />
  <img src="image2.jpg" alt="2" />
  <img src="image3.jpg" alt="3" />
</Marquee>

Scroll-Synced Marquee

<Marquee dir="left" speed={120} scrollFollow={true} scrollSpeed={3}>
  <div>Scroll the page to see the effect</div>
</Marquee>

Changelog

v0.3.0

  • 🎨 BREAKING: Removed alignVertical prop - vertical marquees now use native flex-column layout
  • ✨ Added proper Y-axis animations for vertical directions (up/down)
  • 🎨 Smart gradient overlays that auto-adapt to marquee orientation
  • 🔧 Refactored animation engine to support both X and Y axis seamlessly
  • 📊 Improved dimension calculations for vertical marquees

v0.2.4

  • ✨ Added intelligent container detection to prevent recursive expansion
  • 🚀 Enhanced duplicate calculation algorithm for better performance
  • 🔧 Improved seamless looping with smarter target width calculation
  • 📝 Added comprehensive debug logging for development
  • 🛡️ Added safety limits to prevent extreme duplicate scenarios