https://kotlinlang.org logo
#compose
Title
# compose
a

Anton Shilov

10/19/2021, 2:31 PM
Hello folks! Is there a way to get the current progress of
Transition
on a more granular level rather than current/target state? I'm trying to use
Transition.playTimeNanos
and
Transition.totalDurationNanos
. But total duration is calculated only in seek mode, which as I assume is reserved for tooling. cc @Doris Liu
Copy code
val progress = derivedStateOf {
        if (transition.totalDurationNanos != 0L)
            // total duration is always 0 unles you're in a seek mode
            transition.playTimeNanos / transition.totalDurationNanos
        else 0L
    }
z

Zach Klippenstein (he/him) [MOD]

10/19/2021, 5:06 PM
Please don’t @ specific googlers (see the CoC).
a

Anton Shilov

10/20/2021, 8:17 AM
My bad, won't happen again 🙏
d

Doris Liu

10/25/2021, 7:15 PM
Sorry just saw this - I was on vacation last week. 🙂 What are you trying to achieve with the current progress of a
Transition
? Note that total duration of a Transition is subject to change when the transition gets interrupted. Therefore
totalDurationNanos
is more meaningful in the seeking scenario, where
Transition
disables its interruption handling mechanism.