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

omni-carousel

v0.2.6

Published

A lightweight carousel to enhance scrollable areas

Readme

Omni Carousel

A JavaScript library to enhance scrollable areas

Omni Carousel is a library that takes CSS-only carousels that work like this and adds enhancements and affordances like these.

Omni Carousel leaves the markup and layout up to the author and focuses on the things you cannot do without JavaScript.

Features

  • Enhances scrollable areas with:
    • Better keyboard support
    • Button handling (previous/next/start/end)
    • Indicators (that are also navigation controls)
  • Adds CSS state classes for conditional styling
  • Works with different setups:
    • Responsive slides
    • Full-width slides
    • Fixed-width slides
    • Fixed-width slides of different widths
    • Peek-a-boo slides
  • Autodetects scroll alignment from CSS
  • Scrolls one slide at a time or as many as fit automatically
  • Responds automatically to changes in the track width
  • Caches slide and navigation data to reduce DOM queries
  • Uses fully configurable CSS selectors
  • Sets up lazily (only when needed)
  • Uses browser APIs exclusively
  • Fully typed

Features not supported

  • RTL mode
  • Vertical mode
  • Dynamic slides
  • Customizable scroll duration

Browser support

  • Chrome v88+ (Jan 2021)
  • Firefox v89+ (Jun 2021)
  • Safari v15.4+ (Mar 2022)

In older browsers Omni logs the features it looked for and didn’t find and then exits.

The features Omni checks for are:

  1. CSS scroll-behavior
  2. CSS aspect-ratio (good rough proxy for several browser APIs)

Quick start

Expected markup

Omni needs THREE things:

  • A root container
  • A slide track inside it
  • Two or more slides inside the track
<div class="carousel"><!--Root container-->
  <ul data-omni-track><!--Track for the slides-->
    <li data-omni-slide>Slide 1</li><!--Two or more slides-->
    <li data-omni-slide>Slide 2</li>
    <!-- More slides -->
  </ul>
  
  <!--Optional navigation buttons that are handled if present-->
  <button data-omni-button-start>First</button>
  <button data-omni-button-prev>Previous</button>
  <button data-omni-button-next>Next</button>
  <button data-omni-button-end>Last</button>

  <!--Optional container for Omni’s autogenerated indicators-->
  <div data-omni-indicators></div>
</div>

The data-omni-* attributes are the default selectors of Omni. You can change them in the configuration options or add your own classes next to them and use those.

For a complete example with all markup options, see HTML markup.

For the CSS needed to make a functional scroller/carousel, see:

For conditional styling using the Omni classes, see CSS state classes

Installation

npm install omni-carousel

Initialization

import { createOmniCarousel } from 'omni-carousel';

const root = document.querySelector('.carousel');
const carousel = createOmniCarousel(root);

carousel.init();

createOmniCarousel also takes a second argument, for passing configuration options

Example:

createOmniCarousel(root, { scrollSteps: 'auto' });

NOTE. You don’t have to tell Omni anything about the selector you use for the root. Omni just expects a root with a track and two or more slides in the track.

Development

To work on Omni Carousel:

#
# Clone and install dependencies
#
git clone https://github.com/demetris/omni-carousel.git
cd omni-carousel
npm install

Then:

  • npm run dev — Start the whole project (site and lib) and watch for changes
  • npm run lint — Check code style in the TypeScript files
  • npm run typecheck — Check the TypeScript types
  • cd lib && npm run build — Build the library