From 69921e0c755be7ff71d1e19f70b6179e432b8b0b Mon Sep 17 00:00:00 2001 From: Ryu <87907656+Ryu0118@users.noreply.github.com> Date: Wed, 20 Sep 2023 07:33:55 +0900 Subject: [PATCH] Fix crash (#134) --- Sources/PagerSettings.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/PagerSettings.swift b/Sources/PagerSettings.swift index c529836..3ee6741 100644 --- a/Sources/PagerSettings.swift +++ b/Sources/PagerSettings.swift @@ -127,7 +127,7 @@ public class PagerSettings: ObservableObject where SelectionType: @Published private(set) var itemsOrderedByIndex = [SelectionType]() private func recalculateTransition() { - let indexAndPercentage = -contentOffset / width + let indexAndPercentage = width == 0 ? 0 : -contentOffset / width let percentage = (indexAndPercentage + 1).truncatingRemainder(dividingBy: 1) let lowIndex = Int(floor(indexAndPercentage)) transition = TransitionProgress(from: itemsOrderedByIndex[safe: lowIndex], to: itemsOrderedByIndex[safe: lowIndex+1], percentage: percentage)