From 387bfe6b2890fc75bf535656f3e635ed1568309a Mon Sep 17 00:00:00 2001 From: arinming Date: Sun, 6 Oct 2024 23:17:04 +0900 Subject: [PATCH] =?UTF-8?q?[FIX/#275]=20=EB=B0=B0=EB=84=88=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/search/component/ImageSlider.kt | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt b/feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt index 15cefabe..cd08de88 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt @@ -27,11 +27,9 @@ fun ImageSlider( images: List, onAdvertisementClick: () -> Unit, ) { - val infiniteImages = remember { images + images + images } val pagerState = rememberPagerState( - initialPage = images.size, - initialPageOffsetFraction = 0f, - pageCount = { infiniteImages.size } + initialPage = 0, + pageCount = { Int.MAX_VALUE } ) val autoScroll = remember { mutableStateOf(true) } @@ -41,21 +39,12 @@ fun ImageSlider( delay(3000) if (!pagerState.isScrollInProgress) { val nextPage = pagerState.currentPage + 1 - pagerState.animateScrollToPage(nextPage % infiniteImages.size) + pagerState.animateScrollToPage(nextPage) } } } } - LaunchedEffect(pagerState.currentPage) { - val currentPageMod = pagerState.currentPage % images.size - if (pagerState.currentPage < images.size) { - pagerState.scrollToPage(pagerState.currentPage + images.size) - } else if (pagerState.currentPage >= 2 * images.size) { - pagerState.scrollToPage(pagerState.currentPage - images.size) - } - } - Column( modifier .fillMaxWidth() @@ -69,10 +58,11 @@ fun ImageSlider( HorizontalPager( state = pagerState, modifier = modifier, - beyondViewportPageCount = infiniteImages.size + beyondViewportPageCount = 1 ) { currentPage -> + val pageIndex = currentPage % images.size Image( - painter = painterResource(id = infiniteImages[currentPage % images.size]), + painter = painterResource(id = images[pageIndex]), contentDescription = null, modifier = modifier .fillMaxWidth()