Property

progress

The fraction of the progress going from currentValue to closestValue, within [0f..1f] bounds, or 1f if the AnchoredDraggableState is in a settled state.

Source set: Common
val progress: Float by
        derivedStateOf(structuralEqualityPolicy()) {
            val a = anchors.positionOf(currentValue)
            val b = anchors.positionOf(closestValue)
            val distance = abs(b - a)
            if (!distance.isNaN() && distance > 1e-6f) {
                val progress = (this.requireOffset() - a) / (b - a)
                // If we are very close to 0f or 1f, we round to the closest
                if (progress < 1e-6f) 0f else if (progress > 1 - 1e-6f) 1f else progress
            } else 1f
        }

The fraction of the progress going from currentValue to closestValue, within 0f..1f bounds, or 1f if the AnchoredDraggableState is in a settled state.

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: