Carousels require the use of an id
on the outermost container, .carousel
, for carousel controls to function properly. When adding multiple carousels, or when changing a carousel's id
, be sure to update the relevant controls.
Use data attributes to easily control the position of the carousel. data-slide
accepts the keywords prev
or next
, which alters the slide position relative to its current position. Alternatively, use data-slide-to
to pass a raw slide index to the carousel data-slide-to="2"
, which shifts the slide position to a particular index beginning with 0
.
The data-ride="carousel"
attribute is used to mark a carousel as animating starting at page load.
Call carousel manually with:
wvusUikit('.carousel').carousel()
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-interval=""
.
Name | type | default | description |
---|---|---|---|
interval | number | 5000 | The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle. |
pause | string | "hover" | Pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. |
wrap | boolean | true | Whether the carousel should cycle continuously or have hard stops. |
Initializes the carousel with an optional options object
and starts cycling through items.
wvusUikit('.carousel').carousel({
interval: 2000
})
Cycles through the carousel items from left to right.
Stops the carousel from cycling through items.
Cycles the carousel to a particular frame (0 based, similar to an array).
Cycles to the previous item.
Cycles to the next item.
Bootstrap's carousel class exposes two events for hooking into carousel functionality.
Both events have the following additional properties:
direction
: The direction in which the carousel is sliding (either "left"
or "right"
).relatedTarget
: The DOM element that is being slid into place as the active item.Event Type | Description |
---|---|
slide.bs.carousel | This event fires immediately when the slide instance method is invoked. |
slid.bs.carousel | This event is fired when the carousel has completed its slide transition. |
wvusUikit('#myCarousel').on('slide.bs.carousel', function () {
// do something…
})