fix: Trying to round NaN

This commit is contained in:
Ahmad Ansori Palembani 2024-06-06 08:00:58 +07:00
parent 902b6f6486
commit 2c76508c92
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -86,10 +86,14 @@ class CrossFadeChangeHandler : AnimatorChangeHandler {
animatorSet.duration = if (isPush) { animatorSet.duration = if (isPush) {
200 200
} else { } else {
from?.let { try {
val startX = from.width.toFloat() * 0.2f from?.let {
((startX - it.x) / startX) * 150f val startX = from.width.toFloat() * 0.2f
}?.roundToLong() ?: 150 ((startX - it.x) / startX) * 150f
}?.roundToLong()
} catch (e: IllegalArgumentException) {
null
} ?: 150
} }
animatorSet.doOnCancel { to?.x = 0f } animatorSet.doOnCancel { to?.x = 0f }
animatorSet.doOnEnd { to?.x = 0f } animatorSet.doOnEnd { to?.x = 0f }