A lightweight, no dependency, implementation of a carousel. There is minimal CSS provided to help guide the carousel's behavior. As for visual styling, every site has a different theme, so it's better that you provide your own CSS.
Create a new carousel instance by passing a CSS selector of your carousel to the Carousel class. Each of the immediate children will be considered a slide.
const carouselControls = new Carousel(selector[, options])
Example
First slide
Third slide
const myCarousel = new Carousel('.my-carousel', {
duration: 500
})
Here is the new HTML structure generated from the previous code. Use the class names to customize your own CSS theme.
Options are defined as a Javascript object.
The carousel constructor returns controls for that carousel.
const myCarousel = new Carousel('.my-carousel')
/* Transition to the next slide */
myCarousel.next()
All these examples use the same basic theme located in the source code of this page. You can use it as a starting point, or create your own. Check out the generated HTML structure in the Usage section above.