Update predictive back animations to use interpolation curve of (0.1, 0.1, 0, 1)
This commit is contained in:
1 parent
f23020cc6f
commit
c8207308a8
2 files changed
+7
-5
No files matched your search
@@ -3,7 +3,6 @@ package com.hippo.ehviewer.ui.main
|
||||
import androidx.activity.compose.PredictiveBackHandler
|
||||
import androidx.compose.animation.core.Animatable
|
||||
import androidx.compose.animation.core.AnimationSpec
|
||||
import androidx.compose.animation.core.EaseOut
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.MutatePriority
|
||||
import androidx.compose.foundation.MutatorMutex
|
||||
@@ -34,6 +33,7 @@ import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.layout.layout
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.util.lerp
|
||||
import com.hippo.ehviewer.ui.tools.PredictiveBackEasing
|
||||
import com.hippo.ehviewer.ui.tools.delegateSnapshotUpdate
|
||||
import com.hippo.ehviewer.ui.tools.snackBarPadding
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
@@ -158,7 +158,7 @@ fun FabLayout(
|
||||
try {
|
||||
state.mutatorMutex.mutate(MutatePriority.UserInput) {
|
||||
flow.collect {
|
||||
val eased = EaseOut.transform(it.progress)
|
||||
val eased = PredictiveBackEasing.transform(it.progress)
|
||||
state.expandProgress.snapTo(1 - eased)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import androidx.activity.BackEventCompat
|
||||
import androidx.activity.compose.PredictiveBackHandler
|
||||
import androidx.compose.animation.core.Animatable
|
||||
import androidx.compose.animation.core.AnimationSpec
|
||||
import androidx.compose.animation.core.EaseOut
|
||||
import androidx.compose.animation.core.CubicBezierEasing
|
||||
import androidx.compose.animation.core.Easing
|
||||
import androidx.compose.animation.core.VectorConverter
|
||||
import androidx.compose.animation.core.spring
|
||||
@@ -23,6 +23,8 @@ import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
val PredictiveBackEasing = CubicBezierEasing(0.1f, 0.1f, 0f, 1f)
|
||||
|
||||
/* enable 0 1
|
||||
* animationProgress 1F 0F
|
||||
*
|
||||
@@ -41,7 +43,7 @@ import kotlinx.coroutines.launch
|
||||
fun animateFloatMergePredictiveBackAsState(
|
||||
enable: Boolean,
|
||||
animationSpec: AnimationSpec<Float> = spring(),
|
||||
predictiveBackInterpolator: Easing = EaseOut,
|
||||
predictiveBackInterpolator: Easing = PredictiveBackEasing,
|
||||
finishedListener: ((Float) -> Unit)? = null,
|
||||
onBack: () -> Unit,
|
||||
): State<Float> {
|
||||
@@ -84,7 +86,7 @@ fun animateFloatMergePredictiveBackAsState(
|
||||
fun animateFloatMergeOneWayPredictiveBackAsState(
|
||||
enable: Boolean,
|
||||
animationSpec: AnimationSpec<Float> = spring(),
|
||||
predictiveBackInterpolator: Easing = EaseOut,
|
||||
predictiveBackInterpolator: Easing = PredictiveBackEasing,
|
||||
onBack: suspend () -> Unit,
|
||||
): State<Float> {
|
||||
val animatable = remember { Animatable(0f, Float.VectorConverter) }
|
||||
|
||||
Reference in new issue
Block a user