From a3bc9023c7c03516953f8e9d67f2a24a981a26fc Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Sat, 31 Oct 2026 02:41:22 +0100 Subject: [PATCH] fix(android): the banner no longer stops half way through a turn The turn was a LaunchedEffect keyed on the pager's current page, and the current page flips half way through a scroll. The effect restarted there, cancelling its own animation and leaving two titles side by side until the next swipe. It is keyed on the settled page now. --- .../src/main/java/io/narl/protonstream/ui/LibraryScreen.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/java/io/narl/protonstream/ui/LibraryScreen.kt b/android/app/src/main/java/io/narl/protonstream/ui/LibraryScreen.kt index 61fc256..c8f6185 100644 --- a/android/app/src/main/java/io/narl/protonstream/ui/LibraryScreen.kt +++ b/android/app/src/main/java/io/narl/protonstream/ui/LibraryScreen.kt @@ -851,9 +851,12 @@ private fun FeaturedBanner( val pager = rememberPagerState { titles.size } val dragged by pager.interactionSource.collectIsDraggedAsState() if (titles.size > 1 && !dragged) { - LaunchedEffect(pager.currentPage, titles.size) { + // Keyed on the settled page, not the current one: the current page + // flips half way through a turn, and restarting this effect there + // cancelled the turn and left the banner stuck between two titles. + LaunchedEffect(pager.settledPage, titles.size) { delay(HOLD_MS) - pager.animateScrollToPage((pager.currentPage + 1) % titles.size, animationSpec = tween(TURN_MS)) + pager.animateScrollToPage((pager.settledPage + 1) % titles.size, animationSpec = tween(TURN_MS)) } } // Most of a phone's first screen, but never so much of a tablet's that