Skip to content

Commit 4a1560f

Browse files
committed
library: MiuixIndication: Modify Easing
1 parent 40ddd00 commit 4a1560f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

miuix/src/commonMain/kotlin/top/yukonga/miuix/kmp/utils/MiuixIndication.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package top.yukonga.miuix.kmp.utils
55

66
import androidx.compose.animation.core.Animatable
7+
import androidx.compose.animation.core.LinearEasing
78
import androidx.compose.animation.core.tween
89
import androidx.compose.foundation.Indication
910
import androidx.compose.foundation.IndicationNodeFactory
@@ -22,11 +23,11 @@ import kotlinx.coroutines.isActive
2223
import kotlinx.coroutines.launch
2324
import top.yukonga.miuix.kmp.interfaces.HoldDownInteraction
2425

25-
private const val ANIMATION_DURATION_MS = 150
26+
private const val ANIM_DURATION_MS = 120
2627
private const val HOVER_ALPHA_DELTA = 0.06f
2728
private const val FOCUS_ALPHA_DELTA = 0.08f
28-
private const val PRESS_ALPHA_DELTA = 0.1f
29-
private const val HOLD_DOWN_ALPHA_DELTA = 0.1f
29+
private const val PRESS_ALPHA_DELTA = 0.10f
30+
private const val HOLD_DOWN_ALPHA_DELTA = 0.10f
3031

3132
/**
3233
* Miuix default [Indication] that draws a rectangular overlay when pressed.
@@ -73,15 +74,21 @@ class MiuixIndication(
7374
coroutineScope.launch {
7475
if (coroutineContext.isActive) {
7576
pressedAnimation?.join()
76-
animatedAlpha.animateTo(0f, tween(ANIMATION_DURATION_MS))
77+
animatedAlpha.animateTo(
78+
targetValue = targetAlpha.coerceIn(0f, 0.10f),
79+
animationSpec = tween(durationMillis = ANIM_DURATION_MS, easing = LinearEasing)
80+
)
7781
}
7882
}
7983
} else {
8084
pressedAnimation?.cancel()
8185
restingAnimation?.cancel()
8286
pressedAnimation =
8387
coroutineScope.launch {
84-
animatedAlpha.animateTo(targetAlpha, tween(ANIMATION_DURATION_MS))
88+
animatedAlpha.animateTo(
89+
targetValue = targetAlpha.coerceIn(0f, 0.10f),
90+
animationSpec = tween(durationMillis = ANIM_DURATION_MS, easing = LinearEasing)
91+
)
8592
}
8693
}
8794
}

0 commit comments

Comments
 (0)