ios: scroll without animation when clicking
This commit is contained in:
@@ -52,20 +52,26 @@ struct SybilChatTranscriptView: View {
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.scrollDismissesKeyboard(.interactively)
|
||||
.onAppear {
|
||||
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom)
|
||||
scrollToBottom(with: proxy, animated: false)
|
||||
}
|
||||
.onChange(of: messages.map(\.id)) { _, _ in
|
||||
withAnimation(.easeOut(duration: 0.22)) {
|
||||
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom)
|
||||
}
|
||||
scrollToBottom(with: proxy, animated: !isLoading)
|
||||
}
|
||||
.onChange(of: isSending) { _, _ in
|
||||
withAnimation(.easeOut(duration: 0.22)) {
|
||||
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom)
|
||||
}
|
||||
scrollToBottom(with: proxy, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user