Omni Carousel Search Omni docs and demos…

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 can only do with JavaScript.

Features

Features not supported

Browser support

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:

<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: