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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@magic-spells/scrolling-content

v1.0.0

Published

Scrolling content web component with smooth infinite animation.

Readme

Scrolling Content Web Component

A lightweight, performant Web Component for creating smooth infinite scrolling content. Perfect for displaying logos, announcements, testimonials, or any content that needs to scroll continuously across the screen.

Live Demo

Features

  • No dependencies
  • Lightweight and performant
  • Smooth animations that adapt to device refresh rates
  • Infinite loop with automatic content duplication
  • Interactive hover-to-pause and drag-to-scroll
  • Responsive speed settings for mobile and desktop
  • Customizable gap spacing with CSS variables
  • Touch-friendly on mobile devices

Installation

npm install @magic-spells/scrolling-content
// Add to your JavaScript file
import '@magic-spells/scrolling-content';

Or include directly in your HTML:

<script src="https://unpkg.com/@magic-spells/scrolling-content"></script>

Usage

<scrolling-content mobile-speed="40" desktop-speed="60">
  <scrolling-track>
    <div>🚀 Web Components</div>
    <div>⚡ Lightning Fast</div>
    <div>🎨 Fully Customizable</div>
    <div>📱 Mobile Friendly</div>
    <!-- Component automatically wraps content and duplicates it -->
  </scrolling-track>
</scrolling-content>

<!-- Control gap with CSS -->
<style>
  scrolling-content {
    --scrolling-content-gap: 1rem;
  }
</style>

How It Works

  • Content is wrapped in <scrolling-item> and is duplicated until it fills at least 200% of the container width.
  • The component automatically starts scrolling when loaded.
  • The track smoothly scrolls left, creating an infinite loop by resetting position when one full cycle completes.
  • Hovering over the content pauses the animation.
  • You can drag the content to manually scroll (touch-friendly on mobile).
  • Different speeds can be set for mobile and desktop devices with a customizable breakpoint.

Configuration

The scrolling content can be configured using the following attributes:

| Attribute | Description | Default | | --------------- | ----------------------------------------------------------------------------- | ------- | | mobile-speed | Animation speed in pixels per second for mobile devices (≤ breakpoint width) | 40 | | desktop-speed | Animation speed in pixels per second for desktop devices (> breakpoint width) | 60 | | breakpoint | Screen width in pixels that determines mobile vs desktop speed | 767 |

Track Configuration

| Attribute | Description | Default | | --------- | ---------------------------------------------------------- | ----------------- | | gap | Gap between duplicated items in pixels (overrides CSS var) | Uses CSS variable |

Example:

<!-- Fast scrolling with custom breakpoint -->
<scrolling-content mobile-speed="60" desktop-speed="100" breakpoint="1024">
  <scrolling-track gap="30">
    <div>Fast scrolling content</div>
  </scrolling-track>
</scrolling-content>

<!-- Slow, gentle scrolling -->
<scrolling-content mobile-speed="20" desktop-speed="30">
  <scrolling-track>
    <div>Slow scrolling content</div>
  </scrolling-track>
</scrolling-content>

Customization

Styling

The component provides full styling flexibility. Style the content elements however you like:

/* Control gap between items */
scrolling-content {
  --scrolling-content-gap: 2rem;
}

/* Style your content items */
scrolling-track div {
  background: #667eea;
  color: white;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-weight: 500;
}

/* Different themes for different instances */
.logo-carousel {
  --scrolling-content-gap: 3rem;
}

.logo-carousel scrolling-track div {
  background: white;
  border: 2px solid #e0e0e0;
  color: #333;
  font-weight: 600;
}

CSS Variables

| Variable | Description | Default | | ------------------------- | ---------------------------------------- | ------- | | --scrolling-content-gap | Gap between track items and within items | 1rem |

Example:

/* Global gap setting */
:root {
  --scrolling-content-gap: 1.5rem;
}

/* Per-instance gap setting */
.tight-spacing {
  --scrolling-content-gap: 0.5rem;
}

.wide-spacing {
  --scrolling-content-gap: 3rem;
}

JavaScript API

Methods

  • start(): Starts the scrolling animation (automatically called on load).
  • stop(): Stops the scrolling animation.

Interaction Events

The component automatically handles:

  • Hover: Pauses animation when mouse enters, resumes when mouse leaves
  • Drag: Click and drag to manually scroll the content
  • Touch: Touch-friendly dragging on mobile devices
  • Resize: Automatically recalculates content duplication on window resize

Programmatic Control

const scrollingContent = document.querySelector('scrolling-content');

// Stop the animation
scrollingContent.stop();

// Start the animation
scrollingContent.start();

// Change speed dynamically
scrollingContent.setAttribute('desktop-speed', '80');

Performance

The component uses:

  • requestAnimationFrame for smooth animations that adapt to device refresh rates
  • CSS transform for hardware-accelerated scrolling
  • Efficient content duplication that only runs when needed
  • Automatic cleanup of event listeners

Browser Support

This component works in all modern browsers that support Web Components.

License

MIT