Hi,
I have a WkWebView
named webView
in a SwiftUI
app. I also have a mechanism to capture the spacebar, and when pushed it will result in executing the following piece of code:
Task {
// Left lots of code out for brevity
await webView.scrollPageDown(self)
}
And this works great. The only thing that doesn't work great is that the contents just jumps to the next page and especially when I reach the end of the document it is hard to figure out what the last part was that I just read.
So I want to animate this jump. Somehow combining animation with the async scroll methods doesn't work.
E.g. This doesn't work:
Task {
withAnimation {
await webView.scrollPageDown(self)
}
}
When I compile this code I get the error:
Cannot pass function of type '() async -> Void' to parameter expecting synchronous function type
Does anyone know how to use animation in combination with an async
methods?