From fc0d666366d5c3a71512c4dbd8381eac91f8b4d3 Mon Sep 17 00:00:00 2001 From: anirudhn Date: Sat, 1 Nov 2025 20:19:07 +0545 Subject: [PATCH] Fix scrollbar not showing when animator duration scale animation is turned off (#2398) (cherry picked from commit 09ec9fc8c54e126692ae68ff260058f3be46a5dd) --- .../core/components/VerticalFastScroller.kt | 12 ++++++------ .../tachiyomi/presentation/core/util/Scrollbar.kt | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/components/VerticalFastScroller.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/components/VerticalFastScroller.kt index 12b22ab9f..269aebc58 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/components/VerticalFastScroller.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/components/VerticalFastScroller.kt @@ -47,6 +47,7 @@ import androidx.compose.ui.util.fastForEach import androidx.compose.ui.util.fastLastOrNull import androidx.compose.ui.util.fastMaxBy import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.sample @@ -177,7 +178,8 @@ fun VerticalFastScroller( .collectLatest { if (thumbAllowed()) { alpha.snapTo(1f) - alpha.animateTo(0f, animationSpec = FadeOutAnimationSpec) + delay(ScrollBarVisibilityDurationMillis) + alpha.animateTo(0f, animationSpec = ImmediateFadeOutAnimationSpec) } else { alpha.animateTo(0f, animationSpec = ImmediateFadeOutAnimationSpec) } @@ -366,7 +368,8 @@ fun VerticalGridFastScroller( .collectLatest { if (thumbAllowed()) { alpha.snapTo(1f) - alpha.animateTo(0f, animationSpec = FadeOutAnimationSpec) + delay(ScrollBarVisibilityDurationMillis) + alpha.animateTo(0f, animationSpec = ImmediateFadeOutAnimationSpec) } else { alpha.animateTo(0f, animationSpec = ImmediateFadeOutAnimationSpec) } @@ -460,10 +463,7 @@ object Scroller { private val ThumbLength = 48.dp private val ThumbThickness = 12.dp private val ThumbShape = RoundedCornerShape(ThumbThickness / 2) -private val FadeOutAnimationSpec = tween( - durationMillis = ViewConfiguration.getScrollBarFadeDuration(), - delayMillis = 2000, -) +private val ScrollBarVisibilityDurationMillis = 2000L private val ImmediateFadeOutAnimationSpec = tween( durationMillis = ViewConfiguration.getScrollBarFadeDuration(), ) diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/util/Scrollbar.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/util/Scrollbar.kt index 000915bdf..4ea8c5989 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/util/Scrollbar.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/util/Scrollbar.kt @@ -64,6 +64,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.util.fastFirstOrNull import androidx.compose.ui.util.fastSumBy import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.sample @@ -218,7 +219,8 @@ private fun Modifier.drawScrollbar( .sample(100) .collectLatest { alpha.snapTo(1f) - alpha.animateTo(0f, animationSpec = FadeOutAnimationSpec) + delay(ScrollBarVisibilityDurationMillis) + alpha.animateTo(0f, animationSpec = ImmediateFadeOutAnimationSpec) } } @@ -241,9 +243,9 @@ private fun Modifier.drawScrollbar( } } -private val FadeOutAnimationSpec = tween( +private val ScrollBarVisibilityDurationMillis = ViewConfiguration.getScrollDefaultDelay().toLong() +private val ImmediateFadeOutAnimationSpec = tween( durationMillis = ViewConfiguration.getScrollBarFadeDuration(), - delayMillis = ViewConfiguration.getScrollDefaultDelay(), ) @Preview(widthDp = 400, heightDp = 400, showBackground = true)