Lightweight carousel.
https://luna.liriliri.io/?path=/story/carousel
Add the following script and style to your page.
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/luna-carousel/luna-carousel.css" />
<script src="//cdn.jsdelivr.net/npm/luna-carousel/luna-carousel.js"></script>
You can also get it on npm.
npm install luna-carousel --save
import 'luna-carousel/luna-carousel.css'
import LunaCarousel from 'luna-carousel'
const container = document.getElementById('container')
const carousel = new LunaCarousel(container, { interval: 5000 })
carousel.append('<div style="background:#e73c5e;">ITEM 1</div>')
- interval(number): Time between automatically cycling.
Append item.
Clear all items.
Cycle through the carousel items.
Get current index, starting from 0, -1 means no items.
Insert item at given position.
Slide to the next item.
Stop cycling.
Slide to the previous item.
Slide to the item at given index.