From d547dade04f528ab51bf6cc1a0ef3cbf0e719c28 Mon Sep 17 00:00:00 2001 From: OlegAba Date: Sat, 11 Feb 2023 00:50:44 -0500 Subject: [PATCH] Use top anchor for scroll to top event Changelog-Fixed: Scroll to top of events instead of the bottom Closes: #570 --- damus/Views/EventDetailView.swift | 6 +++--- damus/Views/TimelineView.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/damus/Views/EventDetailView.swift b/damus/Views/EventDetailView.swift index d4e3ed12..d8654392 100644 --- a/damus/Views/EventDetailView.swift +++ b/damus/Views/EventDetailView.swift @@ -33,14 +33,14 @@ func print_event(_ ev: NostrEvent) { print(ev.description) } -func scroll_to_event(scroller: ScrollViewProxy, id: String, delay: Double, animate: Bool) { +func scroll_to_event(scroller: ScrollViewProxy, id: String, delay: Double, animate: Bool, anchor: UnitPoint = .bottom) { DispatchQueue.main.asyncAfter(deadline: .now() + delay) { if animate { withAnimation { - scroller.scrollTo(id, anchor: .bottom) + scroller.scrollTo(id, anchor: anchor) } } else { - scroller.scrollTo(id, anchor: .bottom) + scroller.scrollTo(id, anchor: anchor) } } } diff --git a/damus/Views/TimelineView.swift b/damus/Views/TimelineView.swift index 9625ebd1..7e3f6f29 100644 --- a/damus/Views/TimelineView.swift +++ b/damus/Views/TimelineView.swift @@ -77,7 +77,7 @@ struct TimelineView: View { guard let event = events.filter(self.filter).first else { return } - scroll_to_event(scroller: scroller, id: event.id, delay: 0.0, animate: true) + scroll_to_event(scroller: scroller, id: event.id, delay: 0.0, animate: true, anchor: .top) } } }