Stop the macOS transcript jumping while scrolling
This commit is contained in:
@@ -495,6 +495,7 @@ private struct TranscriptScroll: View {
|
||||
@Environment(Store.self) private var store
|
||||
@Environment(\.paneAccent) private var accent
|
||||
@ViewState private var position = ScrollPosition(edge: .bottom)
|
||||
@ViewState private var scrolling = false
|
||||
|
||||
var body: some View {
|
||||
let running = model.running
|
||||
@@ -536,13 +537,16 @@ private struct TranscriptScroll: View {
|
||||
.onScrollGeometryChange(for: ScrollMetrics.self) { g in
|
||||
ScrollMetrics(content: g.contentSize.height, visible: g.visibleRect.height, distance: g.contentSize.height - g.visibleRect.maxY)
|
||||
} action: { old, new in
|
||||
if new.content != old.content || new.visible != old.visible {
|
||||
if model.stuck && new.distance > 1 {
|
||||
position.scrollTo(edge: .bottom)
|
||||
}
|
||||
if scrolling {
|
||||
model.stuck = new.distance < 80
|
||||
return
|
||||
}
|
||||
model.stuck = new.distance < 80
|
||||
if model.stuck && new.distance > 1 && (new.content != old.content || new.visible != old.visible) {
|
||||
position.scrollTo(edge: .bottom)
|
||||
}
|
||||
}
|
||||
.onScrollPhaseChange { _, phase in
|
||||
scrolling = phase.isScrolling
|
||||
}
|
||||
.onChange(of: model.builder.pending.count) {
|
||||
model.stuck = true
|
||||
|
||||
Reference in New Issue
Block a user