Closed pblanchetteNventive closed 2 years ago
Hi @pblanchetteNventive , can I see your code to change the page? Are you calling it inside a withAnimation
bock and using the Page.update
method? Check out the examples I provide in the repo and you'll see an example of how to do this
Here's how i'm using it
struct ContentView: View {
var body: some View {
VStack {
Pager(
page: page,
data: array,
id: \.id,
content: { index in
VStack{
Text("Item Content")
}
.background(index.color)
})
.itemAspectRatio(1)
.draggingAnimation(.steep(duration: 1.0))
.pagingPriority(.simultaneous)
.loopPages()
.onReceive(timer, perform: {_ in
withAnimation {
page.update(.next)
}
})
.frame(width: 400, height: 200, alignment: .center)
.background(Color.gray.opacity(0.2))
}
}
}
What's timer
and is it being updated in the main thread? Check out ColorExampleView
to see how it works
Thanks, I checked your code in the ColorExampleView and managed to make it work !
Maybe I'm not getting the animation settings right, but I think that the transition from one page to another could be animated in the same way a dragging gesture does.
Maybe adding a modifier to opt-in to perform swipe animation on page change.