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

@oom/carousel

v5.0.0

Published

Carousel built with progressive enhancement in mind

Readme

@oom/carousel

Web component to create a carousel:

  • No dependencies
  • Very light
  • Follows the progressive enhancement strategy:
    • Works with just html
    • Works better with html and css
    • Works much better with html, css and js
    • Works much much better when js polyfills are not needed
  • High performance: Use native scroll to move the elements.
  • No need to wait for javascript to build the carousel.
  • No styles or themes are provided with this package. You decide how the carousel must look.
  • Support for touch devices
  • Support for keyboard
  • Build with modern javascript, using ES6 modules and custom elements

Usage

Usage

Import and register the component with the desired tag name:

import Carousel from "./carousel/carousel.js";

customElements.define("oom-carousel", Carousel);

Create the following HTML code. The accesibility attributes (role, arial-label and tabindex are highly recomended).

<oom-carousel role="region" aria-label="Gallery" tabindex="0">
  <div><img src="http://placehold.it/500x300"></div>
  <div><img src="http://placehold.it/500x300"></div>
  <div><img src="http://placehold.it/500x300"></div>
  <div><img src="http://placehold.it/500x300"></div>
  <div><img src="http://placehold.it/500x300"></div>
  <div><img src="http://placehold.it/500x300"></div>
  <div><img src="http://placehold.it/500x300"></div>
  <div><img src="http://placehold.it/500x300"></div>
  <div><img src="http://placehold.it/500x300"></div>
  <div><img src="http://placehold.it/500x300"></div>
</oom-carousel>

Use css to define the carousel appearance:

oom-carousel {
  overflow-x: scroll;
  display: flex;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
oom-carousel > div {
  flex: 0 0 auto;
  scroll-snap-align: center;
}

Navigation

This package exports also a Navigation custom element to manipulate the carousel:

import { Navigation } from "./carousel/carousel.js";

customElements.define("oom-navigation", Navigation);
<oom-carousel role="region" aria-label="Gallery" tabindex="0">
  ...
</oom-carousel>

<oom-navigation>
  <button value="+1" class="carousel-1">Go 1 slide forward</button>
  <button value="-1" class="carousel--1">Go 1 slide backward</button>
  <button value="prev" class="carousel-prev">Previous page</button>
  <button value="next" class="carousel-next">Next page</button>
  <a href="#slide-6">Go to slide 6</a>
</oom-navigation>

API

//Get/set the slide index
carousel.index = 3; //move to the slide 3
const currIndex = carousel.index; //get the current slide index
carousel.index += 1; //move to the next slide
carousel.index -= 1; //move to the previous slide

//Move the slide using scroll
let atBeginning = carousel.scrollFromLeft === 0; //Determine whether the scroll is at begining
let atTheEnd = carousel.scrollFromRight === 0; //Determine whether the scroll is at the end

carousel.scrollFromLeft = 0; //Performs a scroll to the beginning
carousel.scrollFromRight = 0; //Performs a scroll to the end
carousel.next(); //Move the scroll to next
carousel.prev(); //Move the scroll to previous