Skip to content

Commit

Permalink
Finish animation ignoring cancellation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kanelbulle authored and sjudd committed Sep 19, 2023
1 parent cbdc1e7 commit 06fc8f6
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.drawscope.clipRect
import androidx.compose.ui.graphics.drawscope.translate
import androidx.compose.ui.graphics.painter.Painter
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.withContext

/**
* Transition between a given request's optional placeholder and the resource.
Expand Down Expand Up @@ -141,7 +143,9 @@ internal class CrossFadeImpl(
animatable.animateTo(OPAQUE_ALPHA, animationSpec)
invalidate()
} finally {
animatable.snapTo(OPAQUE_ALPHA)
withContext(NonCancellable) {
animatable.snapTo(OPAQUE_ALPHA)
}
invalidate()
}
}
Expand All @@ -161,4 +165,4 @@ internal class CrossFadeImpl(
draw(size, animatable.value * alpha, colorFilter)
}
}
}
}

0 comments on commit 06fc8f6

Please sign in to comment.