KeylineStateList

public class KeylineStateList


An object that manages a KeylineState and handles shifting the focal keyline range to the left and right of a the carousel container automatically.

This class generates KeylineStates for each discreet step needed to move the focal range from it's default location to the left or right of the carousel container. These state "steps" can then be interpolated between depending on the scroll offset of the carousel to create a smooth shifting of the focal range along the scroll axis while preserving the look and feel of the original KeylineState arrangement.

This class does not need to account for layout direction. CarouselLayoutManager will handle reversing a KeylineState when being laid out right-to-left before constructing a KeylineStateList.

Summary

Public methods

KeylineState
getShiftedState(
    float scrollOffset,
    float minScrollOffset,
    float maxScrollOffset
)

Gets a shifted KeylineState appropriate for a scroll offset.

Public methods

getShiftedState

public KeylineState getShiftedState(
    float scrollOffset,
    float minScrollOffset,
    float maxScrollOffset
)

Gets a shifted KeylineState appropriate for a scroll offset.

The first and last items in a carousel should never detach or scroll away from the edges of the carousel container. To enforce this while still allowing each item in the carousel to enter the focused range when the focused range is not, by default, at the beginning or end of the list, keylines need to shift along the scrolling axis in order to reach every item.

Parameters
float scrollOffset

the scroll offset

float minScrollOffset

the minimum scroll offset. This moves the items as far right in a container as possible.

float maxScrollOffset

the maximum scroll offset. This moves the items as far left in a container as possible.

Returns
KeylineState

a KeylineState that has been shifted according on the scroll offset.