diff --git a/identity/src/main/kotlin/de/jeanlucmakiola/floret/identity/Motion.kt b/identity/src/main/kotlin/de/jeanlucmakiola/floret/identity/Motion.kt index 1cc3721..b91a0a7 100644 --- a/identity/src/main/kotlin/de/jeanlucmakiola/floret/identity/Motion.kt +++ b/identity/src/main/kotlin/de/jeanlucmakiola/floret/identity/Motion.kt @@ -25,7 +25,9 @@ import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp +import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.delay +import kotlinx.coroutines.withContext import kotlin.coroutines.cancellation.CancellationException /** @@ -117,8 +119,10 @@ fun Modifier.predictiveBack( repeat(2) { withFrameNanos { } } if (currentVisible == true) progress.animateTo(0f) } - } catch (_: CancellationException) { - progress.animateTo(0f) + } catch (e: CancellationException) { + // A cancelled gesture also cancels this job, so the spring-back must not be. + withContext(NonCancellable) { progress.animateTo(0f) } + throw e } }