Scroll to top for longform events only
Fixes: ad6a1962 ("Scroll to top of event instead of bottom")
This commit is contained in:
@@ -21,7 +21,7 @@ struct EventDetailView_Previews: PreviewProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func scroll_to_event(scroller: ScrollViewProxy, id: String, delay: Double, animate: Bool, anchor: UnitPoint = .top) {
|
func scroll_to_event(scroller: ScrollViewProxy, id: String, delay: Double, animate: Bool, anchor: UnitPoint = .bottom) {
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
|
||||||
if animate {
|
if animate {
|
||||||
withAnimation {
|
withAnimation {
|
||||||
|
|||||||
@@ -88,7 +88,8 @@ struct ThreadView: View {
|
|||||||
}.navigationBarTitle(NSLocalizedString("Thread", comment: "Navigation bar title for note thread."))
|
}.navigationBarTitle(NSLocalizedString("Thread", comment: "Navigation bar title for note thread."))
|
||||||
.onAppear {
|
.onAppear {
|
||||||
thread.subscribe()
|
thread.subscribe()
|
||||||
scroll_to_event(scroller: reader, id: self.thread.event.id, delay: 0.0, animate: false)
|
let anchor: UnitPoint = self.thread.event.known_kind == .longform ? .top : .bottom
|
||||||
|
scroll_to_event(scroller: reader, id: self.thread.event.id, delay: 0.0, animate: false, anchor: anchor)
|
||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
thread.unsubscribe()
|
thread.unsubscribe()
|
||||||
|
|||||||
Reference in New Issue
Block a user