Controller

Overview

The Controller component parses the request into the proper index and propagates it to the Move component.

Methods

go()

go( control: number | string, allowSameIndex?: boolean ): void

Moves the slider by the following control pattern. Splide#go() is the alias of this method.


scroll()

scroll( destination: number, useIndex?: boolean, snap?: boolean, duration?: number, callback?: AnyFunction ): void

Scrolls the slider to the specified destination or index with updating current and previous indices.


getNext()

getNext( destination?: boolean ): number

Returns a next index. By default, this method resolves the clone index to the real slide index - for example, -1 will be length - 1, but if the destination is true, the method returns -1 as it is.

This method can also return -1 even if the destination is false, which means there is no next slide to go.


getPrev()

getPrev( destination?: boolean ): number

Returns a previous index. By default, this method resolves the clone index to the real slide index - for example, -1 will be length - 1, but if the destination is true, it does not.

This method can also return -1 even if the destionation is false, which means there is no previous slide to go.


getEnd()

getEnd(): number

Returns the end index where the slider can go. For example, if the slider has 10 slides and the perPage option is 3, the slider can go to the slide 8 (the index is 7).


setIndex()

setIndex( index: number ): void

Updates the current index. This method just updates the internal variable and nothing happens to the slider.


getIndex()

getPrev( prev?: boolean ): number

Returns the current or previous index. Splide#index is the alias of the Controller#getIndex().


toIndex()

toIndex( page: number ): number

Converts the page index to the slide index.


toPage()

toPage( index: number ): number

Converts the slide index to the page index.