ios: scroll without animation when clicking

This commit is contained in:
2026-05-02 22:21:18 -07:00
parent 4ad36d9bf6
commit 2da73f802c

View File

@@ -52,20 +52,26 @@ struct SybilChatTranscriptView: View {
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
.scrollDismissesKeyboard(.interactively) .scrollDismissesKeyboard(.interactively)
.onAppear { .onAppear {
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom) scrollToBottom(with: proxy, animated: false)
} }
.onChange(of: messages.map(\.id)) { _, _ in .onChange(of: messages.map(\.id)) { _, _ in
withAnimation(.easeOut(duration: 0.22)) { scrollToBottom(with: proxy, animated: !isLoading)
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom)
}
} }
.onChange(of: isSending) { _, _ in .onChange(of: isSending) { _, _ in
withAnimation(.easeOut(duration: 0.22)) { scrollToBottom(with: proxy, animated: true)
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom)
}
} }
} }
} }
private func scrollToBottom(with proxy: ScrollViewProxy, animated: Bool) {
if animated {
withAnimation(.easeOut(duration: 0.22)) {
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom)
}
} else {
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom)
}
}
} }
private struct MessageBubble: View { private struct MessageBubble: View {