nachonavarro / Pages

📖 A lightweight, paging view solution for SwiftUI
MIT License
556 stars 53 forks source link

Pages doesn't animate when I change current page? #8

Closed jpmcglone-airside closed 4 years ago

jpmcglone-airside commented 4 years ago
Pages(currentPage: self.$currentPage, bounce: true, hasControl: false) {
  Text("A")
  Text("B")
  Text("C")
}

If another view updates self.currentPage, the page surely updates, but it just snaps there. NO animation. Is there a way to make it animate to the next page?

Thanks!

nachonavarro commented 4 years ago

Fixed on the new release. Update Pages and try this

import SwiftUI
import Pages

struct ContentView: View {

    @State var index = 0

    var body: some View {
        Pages(currentPage: $index) {
            Text("First Page")
            Button(action: {
                self.index = 0
            }) {
                Text("Go to Page 1")
            }
            Text("Third Page")
        }
    }
}