stackotter / swift-cross-ui

A cross-platform declarative UI framework, inspired by SwiftUI.
https://stackotter.github.io/swift-cross-ui/documentation/swiftcrossui/
MIT License
651 stars 36 forks source link

Create a way to control whether a scroll view resets scroll position on update #83

Open stackotter opened 7 months ago

stackotter commented 7 months ago

In some circumstances (e.g. when switching out the contents of an article view with a new article) it makes sense for a scroll view to reset its scroll position to the top, and in other circumstances (e.g. a text editor) it makes more sense for a scroll view to maintain its scroll position when its contents are updated. SwiftUI defaults to the latter option (cause even when it's not the best option, it's still usable).

SwiftUI currently has no API for this (afaik), so we get to make up something ourselves 🥳 suggestions welcome!

If there's a workaround for this in SwiftUI I'd be interested to know what it is, because perhaps the workaround is how you're meant to do things in the first place (but I still think that this API would be useful either way).