ios: scroll without animation when clicking
This commit is contained in:
@@ -52,18 +52,24 @@ 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
|
||||||
|
scrollToBottom(with: proxy, animated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func scrollToBottom(with proxy: ScrollViewProxy, animated: Bool) {
|
||||||
|
if animated {
|
||||||
withAnimation(.easeOut(duration: 0.22)) {
|
withAnimation(.easeOut(duration: 0.22)) {
|
||||||
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom)
|
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom)
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
proxy.scrollTo("chat-bottom-anchor", anchor: .bottom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user