CarouselDefaults



Contains the default values used by Carousel.

Summary

Public functions

TargetedFlingBehavior
@Composable
multiBrowseFlingBehavior(
    state: CarouselState,
    decayAnimationSpec: DecayAnimationSpec<Float>,
    snapAnimationSpec: AnimationSpec<Float>
)

A TargetedFlingBehavior that flings and snaps according to the gesture velocity.

Cmn
TargetedFlingBehavior

A TargetedFlingBehavior that flings according to the gesture velocity and does not snap post-fling.

Cmn
TargetedFlingBehavior
@Composable
singleAdvanceFlingBehavior(
    state: CarouselState,
    snapAnimationSpec: AnimationSpec<Float>
)

A TargetedFlingBehavior that limits a fling to one item at a time.

Cmn

Public functions

multiBrowseFlingBehavior

@Composable
fun multiBrowseFlingBehavior(
    state: CarouselState,
    decayAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay(),
    snapAnimationSpec: AnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow)
): TargetedFlingBehavior

A TargetedFlingBehavior that flings and snaps according to the gesture velocity. snapAnimationSpec and decayAnimationSpec can be used to control the animation specs.

The Carousel may use decayAnimationSpec or snapAnimationSpec to approach the target item post-scroll, depending on the gesture velocity. If the gesture has a high enough velocity to approach the target item, the Carousel will use decayAnimationSpec followed by snapAnimationSpec for the final step of the animation. If the gesture doesn't have enough velocity, it will use snapAnimationSpec + snapAnimationSpec in a similar fashion.

Parameters
state: CarouselState

The CarouselState that controls which Carousel this TargetedFlingBehavior will be applied to.

decayAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay()

The animation spec used to approach the target offset when the the fling velocity is large enough to naturally decay.

snapAnimationSpec: AnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow)

The animation spec used to finally snap to the position.

Returns
TargetedFlingBehavior

An instance of TargetedFlingBehavior that performs flinging based on the gesture velocity and then snapping to the closest item post-fling. The animation will be governed by the post scroll velocity and the Carousel will use snapAnimationSpec to approach the snapped position

noSnapFlingBehavior

@Composable
fun noSnapFlingBehavior(): TargetedFlingBehavior

A TargetedFlingBehavior that flings according to the gesture velocity and does not snap post-fling.

Returns
TargetedFlingBehavior

An instance of TargetedFlingBehavior that performs flinging based on the gesture velocity and does not snap to anything post-fling.

singleAdvanceFlingBehavior

@Composable
fun singleAdvanceFlingBehavior(
    state: CarouselState,
    snapAnimationSpec: AnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow)
): TargetedFlingBehavior

A TargetedFlingBehavior that limits a fling to one item at a time. snapAnimationSpec can be used to control the snap animation.

Parameters
state: CarouselState

The CarouselState that controls which Carousel this TargetedFlingBehavior will be applied to.

snapAnimationSpec: AnimationSpec<Float> = spring(stiffness = Spring.StiffnessMediumLow)

The animation spec used to finally snap to the position.

Returns
TargetedFlingBehavior

An instance of TargetedFlingBehavior that performs snapping to the next item. The animation will be governed by the post scroll velocity and the Carousel will use snapAnimationSpec to approach the snapped position