Siema Lightweight and simple carousel with no dependencies

Siemano is a lightweight (only 3kb gzipped) carousel plugin with no dependencies and no styling. As Brad Frost once said, “do that shit yourself”. It is 100% open source and available on GitHub. It is free to use on personal and commercial projects. Use it with your favorite module bundler or by manually injecting the script into your project.

This is a maintained fork of Siema by Paweł Grzybek.

Download Siemano from Github

Installation

Setup is trivially easy. A little bit of markup…

<div class="siema">
  <div>Hi, I'm slide 1</div>
  <div>Hi, I'm slide 2</div>
  <div>Hi, I'm slide 3</div>
  <div>Hi, I'm slide 4</div>
</div>

Option 1: If you are using a module bundler like Webpack or Browserify…

yarn add siemano
import Siema from "siemano";
new Siema();

Option 2: Install from a CDN such as jsDelivr

<script src="https://cdn.jsdelivr.net/gh/DenverCoderOne/siemano@1.6.0/dist/siema.min.js" type="text/javascript"></script>
<script>
  new Siema();
</script>

Option 3: Manually inject the minified script into your website…

<script src="siema.min.js" type="text/javascript"></script>
<script>
  new Siema();
</script>

Options

Siemano comes with a few (optional) settings that you can change by passing an object as an argument. Default values are presented below.

new Siema({
  selector: ".siema",
  duration: 200,
  easing: "ease-out",
  perPage: 1,
  startIndex: 0,
  draggable: true,
  multipleDrag: true,
  threshold: 20,
  loop: false,
  rtl: false,
  autoHeight: false,
  onInit: () => {},
  onChange: () => {},
  onResize: () => {},
});

selector (string or DOM element)
The selector to use as a carousel. Siema will use all immediate children of this selector as slider items. It can be a query string (example) or a DOM element (example).

duration (number)
Slide transition duration in milliseconds (example).

easing (string)
Like a CSS transition-timing-function, it describes the acceleration curve (example).

perPage (number or object)
The number of slides to be shown. It accepts a number (example) or an object (example) for complex responsive layouts.

startIndex (number)
Index (zero-based) of the starting slide (example).

draggable (boolean)
Use dragging and touch swiping (example).

multipleDrag (boolean)
Allow dragging to move multiple slides.

threshold (number)
Touch and mouse dragging threshold (in px) (example).

loop (boolean)
Loop the slides around (example).

rtl (boolean)
Enables layout for languages written from right to left (like Hebrew or Arabic) (example).

autoHeight (boolean)
Enable automatically adjusting the height of the frame to match the currently active slides (example).

onInit (function)
Runs immediately after initialization (example).

onChange (function)
Runs after slide change (example).

onResize (function)
Runs on window resize after the frame is rebuilt (example).

API

As mentioned above, Siemano doesn’t come with many options - just a few useful methods. Combine it with some very basic JavaScript and voila!

prev(howManySlides = 1, callback)
Go to the previous item (example). Optionally slide a few items backward by passing howManySlides (number) argument (example). Optional callback (function) available as a third argument (example).

next(howManySlides = 1, callback)
Go to the next item (example). Optionally slide a few items forward by passing howManySlides (number) argument (example). Optional callback (function) available as a third argument (example).

goTo(index, callback)
Go to an item at a particular index (number) (example). Optional callback (function) available as a second argument (example).

remove(index, callback)
Remove an item at a particular index (number) (example). Optional callback (function) available as a second argument (example).

insert(item, index, callback)
Insert new item (DOM element) at specific index (number) (example). Optional callback (function) available as a third argument (example).

prepend(item, callback)
Prepend new item (DOM element) (example). Optional callback (function) available as a second argument (example).

append(item, callback)
Append a new item (DOM element) (example). Optional callback (function) available as a second argument (example).

destroy(restoreMarkup = false, callback)
Remove all event listeners on the instance (example). Use restoreMarkup to restore the initial markup inside the selector (example). Optional callback (function) available as a third argument (example).

currentSlide
Prints current slide index (example).

Example

Basic carousel with next and previous buttons.

<div class="siema">
  <img src="assets/siema--pink.svg" />
  <img src="assets/siema--yellow.svg" />
  <img src="assets/siema--pink.svg" />
  <img src="assets/siema--yellow.svg" />
</div>

<button class="prev">prev</button>
<button class="next">next</button>
const mySiema = new Siema();
document.querySelector(".prev").addEventListener("click", () => mySiema.prev());
document.querySelector(".next").addEventListener("click", () => mySiema.next());

I’ve also created a Codepen collection with tons of Siema examples.

Check the Codepen collection

Browser support

Other implementations

Contributing

Siemano’s purpose is to provide a basic carousel tool and allow developers to extend it by using the available methods. It doesn’t come with any complex configuration and myriad options — I would like to keep it this way. If you need a more powerful library I recommend the amazing Flickity by David DeSandro or Swiper by iDangero team.

Bug fixes are more than welcome. If you have a feature suggestion please open an issue on Github. Before sending a pull request make sure to use the build task please.

yarn run build

Extra & Thanks

Thanks to Paweł Grzybek for the original Siema.

Siema means ‘hello’ in Polish. When I play around with some code, I always use random names. That’s the whole story behind the name of this one :)

Huge thanks to Jarkko Sibenberg for the cute logo design! I can’t thank BrowserStack enough for giving me a free access to their testing amazing service.