Class

PullToRefreshState

The state of a PullToRefreshBox which tracks the distance that the container and indicator have been pulled.

Source set: Android
public class PullToRefreshState internal constructor(private val anim: Animatable<Float, AnimationVector1D>)

The state of a PullToRefreshBox which tracks the distance that the container and indicator have been pulled.

Each instance of PullToRefreshBox should have its own PullToRefreshState.

PullToRefreshState can be used with custom progress indicators like so:

Properties

distanceFraction

Source set: Android
public val distanceFraction: Float

Distance percentage towards the refresh threshold. 0.0 indicates no distance, 1.0 indicates being at the threshold offset, > 1.0 indicates overshoot beyond the provided threshold.

isAnimating

Source set: Android
public val isAnimating: Boolean

Whether the state is currently animating the indicator to the threshold offset, or back to the hidden offset.

Functions

animateToThreshold

Source set: Android
public suspend fun animateToThreshold(animationSpec: AnimationSpec<Float> = spring())

Animate the distance towards the anchor or threshold position, where the indicator will be shown when refreshing.

Parameters

animationSpec The AnimationSpec used for animating the distance.

animateToHidden

Source set: Android
public suspend fun animateToHidden(animationSpec: AnimationSpec<Float> = spring())

Animate the distance towards the position where the indicator will be hidden when idle.

Parameters

animationSpec The AnimationSpec used for animating the distance.

snapTo

Source set: Android
public suspend fun snapTo(@FloatRange(from = 0.0) targetValue: Float)

Snap the indicator to the desired threshold fraction.

Parameters

targetValue The target fraction to snap to, where 0.0 represents the hidden state and 1.0 represents the threshold position.

Content updated: