Carousel
A virtualized container of items that can be scrolled either horizontally or vertically. As scrolling occurs, a configured number of visible items (slots) are dynamically positioned and reconfigured to give the appearance that all items in the specified range are present.
To create a carousel, a configureSlot function must be provided that will return the configuration object for a given slot index. Slot index 0 is special, and whenever the range is not empty, 0 must be included in the range. The meaning of a slot index, however, is defined by the developer and only interpreted by the developer-provided configureSlot function.
Slot indexes are converted into virtual scroll positions and given to an InfinityScroller. This special scroller allows for negative scroll positioning as well as unbounded scroll range.
Configs
120
Configs
120Common
Other
A callback function that must be provided by the developer to produce configuration objects for the slots in the carousel.
Derived classes may set this config to the name of the instance method to call. The this pointer will be
the carousel instance.
| Parameter | Type | Description |
|---|---|---|
index | Number | The slot index as defined by the range of the carousel. |
carousel | Carousel | The carousel instance. |
slot | Widget | The slot being reconfigured or |
The slot's configuration object.
The first visible slot index. This first visible slot can be read or written using this property. Setting
currentIndex will determine if the transition can be animated by the distance being traveled.
See goto.
The value to set for the disabled config on reserve slots. These slots are not visible to the user but can be tabbed into from visible slots.
When set to 'inert', the inert DOM attribute is also set. This prevents tabbing from a visible slot to
a reserved slot.
The range of slot indexes to be presented in the carousel. Slot indexes greater than or equal to range[0]
and less than range[1] will be rendered.
If this value is null or [0, 0], the carousel will render no items (i.e., it will be empty). See
emptyText.
By default, the carousel's range is unlimited, i.e., range = [-Infinity, Infinity].
The number of slots to render beyond what is visible in the carousel. These reserve items are critical to giving the appearance of continuity as the carousel is being scrolled. A minimum of 1 is required and is generally sufficient for slots that are reasonably large. If slots are small (maybe less than 100px), it may be helpful to provide additional reserve slots.
Set to true to use trapFocus to scroll the carousel when tabbing to slots
that are not currently visible.
NOTE: This only works when configureSlot produces Panel instances.
Due to the position: absolute nature of carousel items, a carousel does not have a natural size. When the
carousel is being sized by its container, this is not a problem, but can be an issue if the carousel is being
used in a layout where its natural size would be important.
Specify true for the carousel to provide a natural size based on the size of its slots. This is done by
setting min-width and/or min-height on the internal elements that contain the absolutely positioned
slots. This may have a modest performance impact due to the required measuring of the slots to provide
these minimums.
By default (shrinkWrap = 'auto'), the carousel enables shrinkWrap support when the carousel's main
element is position: absolute. This can be disabled by setting shrinkWrap = false.
The number of slots to present in the carousel. When set to a number, each slot is given a percentage size
(e.g., "50%" for slots = 2) so they fill the carousel. This is typically required when the carousel is
using shrinkWrap (note: shrink wrapping is enabled by default for position: absolute
carousels).
When null, as many slots as needed to fill the carousel are created. This can produce partially visible
slots.
Setting this value to 'auto' will similarly fill the available space, but once the required number of slots
is determined, they are assigned a percentage size so that they completely fill the carousel.
Set to false to disable scroll snapping and allow free scrolling through the carousel.
Set to true to enable vertical mode. By default, carousels scroll horizontally.
Content
CSS
DOM
Float & align
Layout
misc
Misc
Scrolling
Properties
106
Properties
106Class hierarchy
Other
A callback function that must be provided by the developer to produce configuration objects for the slots in the carousel.
Derived classes may set this config to the name of the instance method to call. The this pointer will be
the carousel instance.
| Parameter | Type | Description |
|---|---|---|
index | Number | The slot index as defined by the range of the carousel. |
carousel | Carousel | The carousel instance. |
slot | Widget | The slot being reconfigured or |
The slot's configuration object.
The first visible slot index. This first visible slot can be read or written using this property. Setting
currentIndex will determine if the transition can be animated by the distance being traveled.
See goto.
The range of slot indexes to be presented in the carousel. Slot indexes greater than or equal to range[0]
and less than range[1] will be rendered.
If this value is null or [0, 0], the carousel will render no items (i.e., it will be empty). See
emptyText.
By default, the carousel's range is unlimited, i.e., range = [-Infinity, Infinity].
The number of slots to render beyond what is visible in the carousel. These reserve items are critical to giving the appearance of continuity as the carousel is being scrolled. A minimum of 1 is required and is generally sufficient for slots that are reasonably large. If slots are small (maybe less than 100px), it may be helpful to provide additional reserve slots.
This will yield true when the carousel is currently scrolling.
Set to true to use trapFocus to scroll the carousel when tabbing to slots
that are not currently visible.
NOTE: This only works when configureSlot produces Panel instances.
Due to the position: absolute nature of carousel items, a carousel does not have a natural size. When the
carousel is being sized by its container, this is not a problem, but can be an issue if the carousel is being
used in a layout where its natural size would be important.
Specify true for the carousel to provide a natural size based on the size of its slots. This is done by
setting min-width and/or min-height on the internal elements that contain the absolutely positioned
slots. This may have a modest performance impact due to the required measuring of the slots to provide
these minimums.
By default (shrinkWrap = 'auto'), the carousel enables shrinkWrap support when the carousel's main
element is position: absolute. This can be disabled by setting shrinkWrap = false.
The number of slots to present in the carousel. When set to a number, each slot is given a percentage size
(e.g., "50%" for slots = 2) so they fill the carousel. This is typically required when the carousel is
using shrinkWrap (note: shrink wrapping is enabled by default for position: absolute
carousels).
When null, as many slots as needed to fill the carousel are created. This can produce partially visible
slots.
Setting this value to 'auto' will similarly fill the available space, but once the required number of slots
is determined, they are assigned a percentage size so that they completely fill the carousel.
Set to false to disable scroll snapping and allow free scrolling through the carousel.
Set to true to enable vertical mode. By default, carousels scroll horizontally.
CSS
DOM
Layout
Misc
State
Widget hierarchy
Functions
81
Functions
81Other
Step the carousel back one slot index.
| Parameter | Type | Description |
|---|---|---|
animate | Boolean | Pass |
Ensures that the given slot index is visible, scrolling if necessary to make it so.
| Parameter | Type | Description |
|---|---|---|
options | Object | Options to configure which slot should be visible and how to scroll if necessary. |
options.index | Number | The index of the slot. |
options.animate | Boolean | Pass |
Step the carousel forward one slot index. See go.
| Parameter | Type | Description |
|---|---|---|
animate | Boolean | Pass |
Steps the slot index of the carousel forward or backward by the given increment.
| Parameter | Type | Description |
|---|---|---|
increment | Number | The number of slot indexes to advance forward ( |
animate | Boolean | Pass |
Sets the slot index of the carousel to the given index.
| Parameter | Type | Description |
|---|---|---|
index | Number | The new slot index for the carousel. |
animate | Boolean | Pass |
Returns the carousel slot index given a logical scroll position (see InfinityScroller).
| Parameter | Type | Description |
|---|---|---|
pos | Number | The logical scroll position from the main InfinityAxis. |
Returns the logical scroll position (see InfinityScroller) given a carousel slot index.
| Parameter | Type | Description |
|---|---|---|
index | Number | The carousel slot index. |