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
let availableWidth = geometry.size.width
ScrollViewReader { proxy in
ScrollView(.horizontal, showsIndicators: false) {
cardsContent
.padding(.horizontal, Design.Spacing.medium)
.frame(minWidth: availableWidth, alignment: .center)
.id("cards_container")
}
.scrollDisabled(cards.count < 3)
.scrollClipDisabled(true) // Prevent clipping during deal animations
.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)
if isLargeScreen {
// iPad: Simple centered layout - no scrolling needed
cardsContent
.padding(.horizontal, Design.Spacing.medium)
.frame(width: availableWidth, alignment: .center)
} else {
// iPhone: Use ScrollView for 3rd card
ScrollViewReader { proxy in
ScrollView(.horizontal, showsIndicators: false) {
cardsContent
.padding(.horizontal, Design.Spacing.medium)
.frame(minWidth: availableWidth, alignment: .center)
.id("cards_container")
}
.scrollDisabled(cards.count < 3)
.scrollClipDisabled(true) // Prevent clipping during deal animations
.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
// Scroll to the active card during interaction
if newIndex >= 4 {
withAnimation(.spring(duration: 0.5)) {
proxy.scrollTo(newIndex, anchor: .center)
.onChange(of: currentRevealIndex) { _, newIndex in
// Scroll to the active card during interaction
if newIndex >= 4 {
withAnimation(.spring(duration: 0.5)) {
proxy.scrollTo(newIndex, anchor: .center)
}
}
}
}