Skip to content

Commit c69304c

Browse files
committed
fix jump on first drag
1 parent 767112f commit c69304c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Sources/Views/HStackSnapCore.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public struct HStackSnapCore<Content: View>: View {
2121
self.scrollOffset = leadingOffset
2222
self.coordinateSpace = coordinateSpace
2323
self.eventHandler = eventHandler
24+
self._prevScrollOffset = State(initialValue: leadingOffset)
2425
}
2526

2627
// MARK: Public
@@ -153,7 +154,7 @@ public struct HStackSnapCore<Content: View>: View {
153154
@State private var scrollOffset: CGFloat
154155

155156
/// Stored offset of previous scroll, so scroll state is resumed between drags.
156-
@State private var prevScrollOffset: CGFloat = 0
157+
@State private var prevScrollOffset: CGFloat
157158

158159
/// Calculated offset based on `SnapLocation`
159160
@State private var targetOffset: CGFloat

0 commit comments

Comments
 (0)