The carousel is a widget that allows horizontal scrolling (with touch or buttons) between a set of items.
The CSS we need to use here is pretty picky, so make sure to check out the CSS tab below.
The compatibility of this with FireFox is adequate (vertical-scroll: enabled is not supported however). Check out our compatibility tables to see which devices and browsers will display the carousel.
data-ur-carousel-component="item"data-ur-carousel-component="button"data-ur-carousel-button-type="prev"/"next"data-ur-carousel-component="view_container"data-ur-carousel-component="scroll_container"data-ur-set="carousel""carousel"
"button"
data-ur-carousel-button-type:"next"/"prev" for the next and previous buttons, respectively"dots"
data-ur-state on the corresponding child
"count"
"view_container"
position:relative.
data-ur-touch: enabled/disableddata-ur-vertical-scroll: enabled/disabled (specify vertical scrolling behavior while touching carousel)data-ur-maps: enabled/disabled (allow images using maps in carousel)data-ur-infinite: enabled/disabled (specify front to back wrapping behavior)data-ur-autoscroll: enabled/disabled (automatically scroll with interval)data-ur-autoscroll-delay: integer (autoscroll delay in seconds)data-ur-autoscroll-dir: next/prev (specify autoscroll direction)data-ur-android3d: enabled/disabled (specify translate3d use on Android 1.6-2.3)data-ur-fill (β): integer (force n carousel items to fit in container width)data-ur-center (β): enabled/disabled (horizontally center current item)"scroll_container"
position:relative.
"item"
float:left style
Ur.Widgets.carousel["ID"]. The following methods are exposed for each widget:
"slideend": event is fired on view_container when sliding ends"slidestart": event is fired on view_container when sliding begins (excluding touch input)jumpToIndex(index): forces the carousel to jump to the specified (zero based) indexonSlideCallbacks(callback): supplies a callback which is called when animation has completedTouch-enabled Widget
More examples of the carousel can be found here, including:
This carousel doesn't allow vertical scrolling on touch screens.
Here we have a carousel that loops from front to back.
Here we have a carousel that scrolls every five seconds with a "dot" indicator. Note that the current element is centered.
In this example, we have a bit of extra javascript to include in the page. We use this to jump to a location in the carousel. It's what we call an "instance" - only for this instance of the carousel will the feature be enabled.
<script type="text/javascript">
x$("[data-ur-carousel-component='item']").click(function(e) {
console.log("You clicked:", e.target.src);
});
x$("#jump").click(function() {
Ur.Widgets["carousel"]["MyFirstCarousel"].jump_to_index(4);
});
</script>
Jump to 5th item