Skip to content

Commit

Permalink
Fix horizontalScrollPosition index preference key update
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelHolec committed Aug 23, 2024
1 parent 0ca1669 commit e448a04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions Sources/Orbit/Components/HorizontalScroll.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public struct HorizontalScroll<Content: View>: View {
guard let scrollTarget else {
return
}
scrolledItemID = scrollTarget.id
scrollTo(id: scrollTarget.id, geometry: geometry, animated: scrollTarget.animated)
}
.onReceive(timer) { output in
Expand Down
5 changes: 5 additions & 0 deletions Sources/Orbit/Support/Layout/HorizontalScrollPosition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ struct HorizontalScrollPositionModifierPreviews: PreviewProvider {
PreviewWrapper {
StateWrapper(0) { $id in
VStack(alignment: .leading, spacing: .medium) {
Text("Current scroll index \(id)")

Heading("Snapping", style: .title3)

HorizontalScroll(spacing: .medium, itemWidth: .ratio(0.95)) {
Expand Down Expand Up @@ -98,6 +100,9 @@ struct HorizontalScrollPositionModifierPreviews: PreviewProvider {
}
}
.screenLayout()
.onAppear {
id = 2
}
}
}
}
Expand Down

0 comments on commit e448a04

Please sign in to comment.