akhbar / siema

Siema - Lightweight and simple carousel in pure JavaScript

Home Page:https://pawelgrzybek.com/siema/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Siema - Lightweight and simple carousel with no dependencies

Full docs with examples: https://pawelgrzybek.com/siema/.

Siema is a lightweight (only 1kb 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 favourite module bundler or by manually injecting the script into your project.

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>

If you are using a module bundler like Webpack or Browserify...

npm i -S siema

// or

yarn add siema
import Siema from 'siema';
new Siema();

...or manually inject the minified script into your website.

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

Options

Siema 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,
  threshold: 20,
  loop: false,
});
  • selector - (string) specify the parent element
  • duration - (number) slide transition duration (in ms)
  • easing - (string) the same as transition-timing-function in CSS
  • perPage - (number) the number of slides to be shown
  • startIndex - (number) index of the starting slide (zero-based)
  • draggable - (boolean) use dragging and touch swiping
  • threshold - (number) touch and mouse dragging threshold (in px)
  • loop - (boolean) loop the slides around

API

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

  • next() - go to next slide
  • prev() - go to previous slide
  • goTo(index) - go to a specific slide
  • currentSlide - index of the current active slide (read only)

Siema used in production

Nowhere yet — I've just built it. If you use it on your website please let me know and I will make sure to add the URL of your project here.

Contributing

Siema'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 welcone. 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.

npm run build

//or

yarn run build

Browser support

  • IE10
  • Chrome 12
  • Firefox 16
  • Opera 15
  • Safari 4
  • Android Browser 4.0
  • iOS Safari 6.0

Extra

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!


Built by Paweł Grzybek | Follow me on: Twitter, Github, Instagram

About

Siema - Lightweight and simple carousel in pure JavaScript

https://pawelgrzybek.com/siema/


Languages

Language:HTML 58.7%Language:JavaScript 32.8%Language:CSS 8.5%