Skip to content

Repository files navigation

Sand Carousel

A simple JavaScript carousel. WARNING, the project is still in development.

About

A screen shot of the carousel My main goal is to make a very simple and light carousel that I can use for my projects. There are still quite a few things that I would like to change. I used vanilla JavaScipt for the initiation and the options, and CSS for the animation.

Usage

  1. Link the stylesheet and the script files from the dist folder:
 ...
<linkrel="stylesheet" href="sand-carousel.css"></head><body>
...
<scriptsrc="sand-carousel.js"></script></body>
  1. Add the required classes sand-carousel and slides-wrapper to the containing elements and slide class to the carousel's items in a markup similar to the one below.

    Please note that the script is adding the carousel's controls in the element with the sand-carosel class. Both sand-carousel and slides-wrapper classes can be applied to one element but that might lead to semantic inconsistencies if the containing element is a list and the slides are list items as in the markup below.

<divclass="sand-carousel"><ulclass="slides-wrapper"><liclass="slide">Slide 1</li><liclass="slide">Slide 2</li><liclass="slide">Slide 3</li></ul></div>
  1. Initiate the carousel by declaring a new instance of the SandCarousel class:
letcontainerSelector=".sand-carousel";letsingleSlideSelector=".slide";letslideDuration=6000;lettransitionDuration=500;// 500ms by dafaultletresizable=false;// false by defailtletautoPlay=true;// true by default// NOTE! The autoplay property in the constructor// is set to false if the slider is resizable// this.autoplay = resizable ? false : autoplayconstSAND_CAROUSEL=newSandCarousel(containerSelector,singleSlideSelector,slideDuration,transitionDuration,resizable,autoPlay);
  1. Then call one of the methods dotControls() or arrowControls():
SAND_CAROUSEL.dotControls();

To do

  • Review of the code;
  • fix the issues;
  • add lazy loadgin.

About

A simple JavaScript carousel 📼

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages