Dead simple carousel. Demo
Clearly not ready for now, it will be a NPM module in few weeks, be patient.
An example is disponible, you can try it but you'll need Gulp to customize.
It's (really) dead simple, actually (it'll change when it'll be on NPM) :
<script>
window.addEventListener('load', () => {
new Carousel(document.querySelector('#demo'), {
// Options
})
})
</script>
Kind: global class
- Carousel
- new Carousel(el, options)
- .itemsToScroll β
number
- .itemsToShow β
number
- .wrapperWidth β
number
- .carouselWidth β
number
- .DOMSetup()
- .setStyles()
- .animation(active)
- .translate(percent)
- .setNavigation()
- .setPagination()
- .setDesktopPagination()
- .setMobilePagination()
- .navigate(to)
- .onResize()
- .onKeyUp(e)
- .onMove(callback)
- .goto(index, [animation])
- .wrapperTransitionEnd()
Param | Type | Default | Description |
---|---|---|---|
el | HTMLElement |
Slider element | |
options | object |
Options object | |
[options.itemsToShow] | number |
1 |
How many element you want to show |
[options.itemsToShowOnMobile] | number |
1 |
How many element you want to show on mobile |
[options.itemsToScroll] | number |
1 |
How many items will be scrolling each time |
[options.itemsToScrollOnMobile] | number |
1 |
How many items will be scrolling each time on mobile |
[options.loop] | boolean |
false |
Loop and end of the slice |
[options.navigation] | boolean |
true |
Arrows to navigate in the slider |
[options.pagination] | boolean |
false |
Add pagination menu |
[options.mobilePagination] | boolean |
options.pagination |
Add pagination on mobile |
[options.infinite] | boolean |
false |
Infinite slider, you'll can't stop it :o |
itemsToScroll getter
Kind: instance property of Carousel
Returns: number
- return itemsToScroll
itemsToShow getter
Kind: instance property of Carousel
Returns: number
- return itemsToShow
containerWidth getter
Kind: instance property of Carousel
Returns: number
- return the width of the container
carouselWidth getter
Kind: instance property of Carousel
Returns: number
- return the width of the carousel root
DOMSetup - Setup the DOM to be ready
Kind: instance method of Carousel
setStyles - Set style for carousel items and wrapper
Kind: instance method of Carousel
animation - Enable or disable animation
Kind: instance method of Carousel
Param | Type | Description |
---|---|---|
active | boolean |
If you want to active the transition ability or not |
translate - Translate the wrapper to slide
Kind: instance method of Carousel
Param | Type | Description |
---|---|---|
percent | number |
How many percent you want to slide |
setNavigation - Create navigation components to scroll in the carousel
Kind: instance method of Carousel
setPagination - Init the pagination following the options
Kind: instance method of Carousel
setDesktopPagination - Create pagination components (dots) on desktop
Kind: instance method of Carousel
setMobilePagination - Create pagination components (dots) on mobile
Kind: instance method of Carousel
navigate - Scroll in the slider to navigate
Kind: instance method of Carousel
Param | Type | Description |
---|---|---|
to | string |
direction of navigation |
onResize - Event window resize
Kind: instance method of Carousel
onKeyUp - Event on keyUp on root
Kind: instance method of Carousel
Param | Type | Description |
---|---|---|
e | type |
event |
onMove - store new callback
Kind: instance method of Carousel
Param | Type | Description |
---|---|---|
callback | moveCallback |
index callback |
goto - Scroll in the slider to navigate
Kind: instance method of Carousel
Param | Type | Default | Description |
---|---|---|---|
index | number |
Slide number | |
[animation] | boolean |
true |
Animate the translation |
wrapperTransitionEnd - Toggled on transition end
Kind: instance method of Carousel
Add touchable
Kind: global class
Param | Type |
---|---|
carousel | Carousel |
startDrag - Draggable start
Kind: instance method of CarouselTouch
Param | Type |
---|---|
e | MouseEvent | TouchEvent |
drag - Mouse or finger is moving
Kind: instance method of CarouselTouch
Param | Type |
---|---|
e | MouseEvent | TouchEvent |
endDrag - Draggable end
Kind: instance method of CarouselTouch
Param | Type |
---|---|
e | MouseEvent | TouchEvent |
Kind: global typedef
Param | Type |
---|---|
index | number |
- Carousel
- CarouselTouch
Add touchable
- moveCallback :
function