Carousel
Abstract
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
Configs are options you supply in a configuration object when creating an instance of this class-
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.
Has a corresponding runtime reserveSlots property.
-
Set to
falseto disable scroll snapping and allow free scrolling through the carousel.Has a corresponding runtime snap property.
-
Set to
trueto enable vertical mode. By default, carousels scroll horizontally.Has a corresponding runtime vertical property.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Carousel class, or subclass thereof.
-
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.
Has a corresponding reserveSlots config.
-
This will yield
truewhen the carousel is currently scrolling. -
Set to
falseto disable scroll snapping and allow free scrolling through the carousel.Has a corresponding snap config.
-
Set to
trueto enable vertical mode. By default, carousels scroll horizontally.Has a corresponding vertical config.
-
Identifies an object as an instance of Carousel class, or subclass thereof.
Functions
Functions are methods available for calling on the class-
sync( )internal
Synchronizes the scroll range and child items based on the current configuration and scroll position. This is called in response to scroll events and when the carousel is reconfigured.