Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2026-01-24 16:46:38 -06:00
parent bfda399fdd
commit b6ba6264f7

View File

@ -92,32 +92,40 @@ struct CompactHandView: View {
GeometryReader { geometry in GeometryReader { geometry in
let availableWidth = geometry.size.width let availableWidth = geometry.size.width
ScrollViewReader { proxy in if isLargeScreen {
ScrollView(.horizontal, showsIndicators: false) { // iPad: Simple centered layout - no scrolling needed
cardsContent cardsContent
.padding(.horizontal, Design.Spacing.medium) .padding(.horizontal, Design.Spacing.medium)
.frame(minWidth: availableWidth, alignment: .center) .frame(width: availableWidth, alignment: .center)
.id("cards_container") } else {
} // iPhone: Use ScrollView for 3rd card
.scrollDisabled(cards.count < 3) ScrollViewReader { proxy in
.scrollClipDisabled(true) // Prevent clipping during deal animations ScrollView(.horizontal, showsIndicators: false) {
.background(Color.clear) cardsContent
.onChange(of: cards.count) { _, newCount in .padding(.horizontal, Design.Spacing.medium)
// When 3rd card is dealt, wait for animation then scroll .frame(minWidth: availableWidth, alignment: .center)
if newCount == 3 { .id("cards_container")
let lastIndex = isBottom ? 4 : 5 }
DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) { .scrollDisabled(cards.count < 3)
withAnimation(.spring(duration: 0.5)) { .scrollClipDisabled(true) // Prevent clipping during deal animations
proxy.scrollTo(lastIndex, anchor: .center) .background(Color.clear)
.onChange(of: cards.count) { _, newCount in
// When 3rd card is dealt, wait for animation then scroll
if newCount == 3 {
let lastIndex = isBottom ? 4 : 5
DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {
withAnimation(.spring(duration: 0.5)) {
proxy.scrollTo(lastIndex, anchor: .center)
}
} }
} }
} }
} .onChange(of: currentRevealIndex) { _, newIndex in
.onChange(of: currentRevealIndex) { _, newIndex in // Scroll to the active card during interaction
// Scroll to the active card during interaction if newIndex >= 4 {
if newIndex >= 4 { withAnimation(.spring(duration: 0.5)) {
withAnimation(.spring(duration: 0.5)) { proxy.scrollTo(newIndex, anchor: .center)
proxy.scrollTo(newIndex, anchor: .center) }
} }
} }
} }