The carousel instance.

Implements

Constructors

Properties

Accessors

Methods

Constructors

  • Creates an instance.

    Parameters

    • el: Element

      is the dom element to control. This should be a container element that holds child elements that will scroll horizontally.

    • options: Options = {}

      are the options to configure this instance.

    Returns Carousel

Properties

behavior: ScrollBehavior = ScrollBehavior.AUTO

Current scroll behavior. Possible values are:

  • 'auto'
  • 'smooth'

Accessors

  • get el(): Element
  • Returns the dom element reference of the carousel which was passed into the constructor.

    Returns Element

    the controlled dom element

  • get id(): string
  • Returns the id-attribute value of the carousel.

    Returns string

    the id of the controlled dom element

  • get index(): Index
  • Returns the current index of the carousel. The returned index is a list (array) of indexes that are currently visible (depending on each item width).

    Returns Index

    a list of visible indexes

  • set index(values): void
  • Sets the current index of the carousel. To set an index you need to pass an array with at least one element. When passing more than one, the rest will be ignored.

    Parameters

    • values: Index

      are the upcoming indexes

    Returns void

  • get items(): HTMLElement[]
  • Returns an array of all child dom elements of the carousel.

    Returns HTMLElement[]

    a list of elements (child elements of the root element)

  • get mask(): null | Element
  • Returns the dom element reference of the mask element that wraps the carousel element.

    Returns null | Element

    the mask dom element

  • get pageIndex(): number
  • Returns the index of the current page.

    Returns number

    the index of the current page

  • get pages(): Pages
  • Returns an array of all pages. Each page is a group of indexes that matches a page.

    Returns Pages

    the list of pages and indexes inside each page

Methods

  • This completely deconstructs the carousel and returns the dom to its initial state.

    Returns void

  • Enforces an update of all enabled components of the carousel. This is, for example, useful when changing the number of items inside the carousel. This also forwards an update call to all attached features.

    Returns void