From 09ec9fc8c54e126692ae68ff260058f3be46a5dd Mon Sep 17 00:00:00 2001 From: anirudhn Date: Sat, 1 Nov 2025 07:34:07 -0700 Subject: [PATCH] Fix scrollbar not showing when animator duration scale animation is turned off (#2398) --- CHANGELOG.md | 1 + .../core/components/VerticalFastScroller.kt | 12 ++++++------ .../tachiyomi/presentation/core/util/Scrollbar.kt | 8 +++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1ffa3d20..e0b86ef5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co - Fix migration "Attempt to invoke virtual method" crash ([@AntsyLich](https://github.com/AntsyLich)) ([#2632](https://github.com/mihonapp/mihon/pull/2632)) - Fix reader "Unable to edit key" error ([@AntsyLich](https://github.com/AntsyLich)) ([#2634](https://github.com/mihonapp/mihon/pull/2634)) - Fix extension download stuck in pending state in some cases ([@c2y5](https://github.com/c2y5)) ([#2483](https://github.com/mihonapp/mihon/pull/2483)) +- Fix scrollbar not showing when animator duration scale animation is turned off ([@anirudhsnayak](https://github.com/anirudhsnayak)) ([#2398](https://github.com/mihonapp/mihon/pull/2398)) ### Improved - Auto refresh extension list whenever a repository is added or removed ([@c2y5](https://github.com/c2y5)) ([#2483](https://github.com/mihonapp/mihon/pull/2483)) 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)