I have a horizontally scrolling ScrollView in SwiftUI. I need to somehow center the element that is shown more than a half. I can't figure out how to get ScrollView position in percent, and I don't know how to optimize using GeometryReader for all possible devices.
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing:10) {
ForEach (sectionData) { item in
GeometryReader { geometry in
SectionView(section: item)
.rotation3DEffect(
Angle(degrees: Double(geometry.frame(in:.global).minX - 30) / -20),
axis: (x: 0.0, y: 10.0, z: 0.0))
}
.frame(width: 275, height: 275)
}
}
.padding(30)
.padding(.bottom, 30)
}
.offset(y: -30)