fermoya / SwiftUIPager

Native Pager in SwiftUI
MIT License
1.3k stars 172 forks source link

[FEAT] Animation when scrolling programmatically #209

Closed ln-12 closed 3 years ago

ln-12 commented 3 years ago

Is your feature request related to a problem? Please describe. When using page.update(.next) and page.update(.previous), the page is changed without any animation.

Describe the solution you'd like Animate the page transition.

Is this possible to implement?

ln-12 commented 3 years ago

For anyone wondering: the solution is to use withAnimation:

withAnimation {
    page.update(.next)
}
fermoya commented 3 years ago

Hi @ln-12 , this is intended. It’s up to the user to use the animation they need:

withAnimation(desiredAnimation) {
  page.update(.next)
}

Please check out ColorsExampleView inside the example project