@@ -31,7 +31,6 @@ import kotlinx.coroutines.launch
3131import top.yukonga.miuix.kmp.basic.LocalPullToRefreshState
3232import top.yukonga.miuix.kmp.basic.RefreshState
3333import kotlin.math.abs
34- import kotlin.math.exp
3534import kotlin.math.sign
3635import kotlin.math.sqrt
3736
@@ -52,11 +51,9 @@ import kotlin.math.sqrt
5251@Stable
5352fun parabolaScrollEasing (currentOffset : Float , newOffset : Float , p : Float = 50f, density : Float ): Float {
5453 val realP = p * density
55- val distance = abs(currentOffset + newOffset / 2 )
56- val ratio = (realP / (sqrt(realP * distance.coerceAtLeast(Float .MIN_VALUE )))).coerceIn(Float .MIN_VALUE , 1f )
57- val nonLinearRatio = ratio * (1 - exp(- distance / realP))
54+ val ratio = (realP / (sqrt(realP * abs(currentOffset + newOffset / 2 ).coerceAtLeast(Float .MIN_VALUE )))).coerceIn(Float .MIN_VALUE , 1f )
5855 return if (sign(currentOffset) == sign(newOffset)) {
59- currentOffset + newOffset * nonLinearRatio
56+ currentOffset + newOffset * ratio
6057 } else {
6158 currentOffset + newOffset
6259 }
@@ -67,12 +64,12 @@ internal val DefaultParabolaScrollEasing: (currentOffset: Float, newOffset: Floa
6764 get() {
6865 val density = LocalDensity .current.density
6966 return { currentOffset, newOffset ->
70- parabolaScrollEasing(currentOffset, newOffset, density = density)
67+ parabolaScrollEasing(currentOffset, newOffset, 20f , density)
7168 }
7269 }
7370
74- internal const val OutBoundSpringStiff = 150f
75- internal const val OutBoundSpringDamp = 0.86f
71+ internal const val OutBoundSpringStiff = 180f
72+ internal const val OutBoundSpringDamp = 1f
7673
7774/* *
7875 * @see overScrollOutOfBound
@@ -267,7 +264,8 @@ fun Modifier.overScrollOutOfBound(
267264 }
268265 lastFlingAnimator = Animatable (offset)
269266 lastFlingAnimator.animateTo(
270- 0f , spring(currentSpringDamp, currentSpringStiff, visibilityThreshold),
267+ 0f ,
268+ spring(currentSpringDamp, currentSpringStiff, visibilityThreshold),
271269 if (currentIsVertical) realAvailable.y else realAvailable.x
272270 ) {
273271 offset = currentScrollEasing(offset, value - offset)
@@ -305,5 +303,5 @@ class OverScrollState {
305303 *
306304 * @see OverScrollState
307305 */
308- val LocalOverScrollState = compositionLocalOf< OverScrollState > { OverScrollState () }
306+ val LocalOverScrollState = compositionLocalOf { OverScrollState () }
309307
0 commit comments