Skip to content

Commit

Permalink
[FIX/#275] 배너 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
arinming committed Oct 6, 2024
1 parent 116b1c0 commit 387bfe6
Showing 1 changed file with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ fun ImageSlider(
images: List<Int>,
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) }

Expand All @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 387bfe6

Please sign in to comment.