Can't correctly scroll to item when ScrollView ignores safe area

97 views Asked by At

For some reason ScrollView should ignore safe area:

ScrollViewReader { proxy in
    ScrollView {
        ...
        ...
    }
    .onChange(of: model.targetID) { id in
        proxy.scrollTo(id, anchor: .top)
    }
}

Everything works good, but the target element appears under the navigation bar (it happens because ScrollView top anchor under the navigation bar too). Is there a way to add any offset when use scrollTo()?

I tried to scroll to element and only after that apply ignoringSafeArea, but it didn't work (scroll jumps back after applying). Somehow I need to have invisible padding for safe area inset that participates in autoscroll, but I haven't any ideas how to implement it.

0

There are 0 answers