JAVASCRIPT
Flexible Carousel
All samples are using Ink.requireModules
, please read how to use it at Ink.requireModules section
Method name | Description |
---|---|
new Carousel_1(selector, [options]) | Constructor |
.autoAdvance([ms]) | Auto-advance the carousel every ms milliseconds. |
.getPage() | Gets the current page index |
.getPagination() | Gets the Ink Pagination element this carousel is using. |
.getSlidesList() | Get a list of your slides (elements with the ".slide" class inside your stage) |
.getSlidesPerPage() | Returns how many slides fit into a page |
.getStageElm() | Get the stage element (your UL with the class ".stage"). |
.getTotalPages() | Get the amount of pages in the carousel. |
.getTotalSlides() | Get the total number of slides |
.nextPage([wrap]) | Goes to the next page |
.previousPage([wrap]) | Goes to the previous page |
.refit() | Repositions elements around. |
.setPage(page, [wrap]) | Sets the current page index |
.stopAutoAdvance() | Stop the carousel from auto-advancing. Calls clearTimeout to cancel the auto-advancer. |
selector
DOM element or element idoptions
Carousel Optionsoptions.autoAdvance
Milliseconds to wait before auto-advancing pages. Set to 0 to disable auto-advance. Defaults to 0.options.axis
Axis of the carousel. Set to 'y' for a vertical carousel. Defaults to 'x'.options.initialPage
Initial index page of the carousel. Defaults to 0.options.spaceAfterLastSlide
trueIf there are not enough slides to fill the full width of the last page, leave white space. Defaults to `true`.options.swipe
Enable swipe support if available. Defaults to true.options.pagination
Either an ul element to add pagination markup to or an `Ink.UI.Pagination` instance to use.options.onChange
Callback to be called when the page changes.Demo
Code
Creating a slideshow is just like creating a carousel, except each slide has the all-100
class, making it fill the whole page.
Demo
Code
Auto-advance the carousel every ms
milliseconds.
ms
{String} Number of milliseconds between advances.Gets the current page index
Gets the Ink Pagination element this carousel is using.
Get a list of your slides (elements with the ".slide" class inside your stage)
Returns how many slides fit into a page
Get the stage element (your UL with the class ".stage").
Get the amount of pages in the carousel.
Get the total number of slides
Goes to the next page
wrap
falseFlag to loop from last page to first page.Goes to the previous page
wrap
falseFlag to loop from first page to last page.Repositions elements around.
Measure the carousel once again, adjusting the involved elements' sizes. This is called automatically when the window resizes, in order to cater for changes from responsive media queries, for instance.
Sets the current page index
page
Index of the destination page.wrap
falseFlag to activate circular counting (for example, if you set the page to `5` and there are only 4 pages, you're actually going to the first page).Stop the carousel from auto-advancing. Calls clearTimeout to cancel the auto-advancer.