-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page change animated twice #18
Comments
Setting |
Thanks for sharing! I am experiencing the same thing. It only fixes it for scroll gestures, but when changing the index of the page programmatically, it does not animate. |
PageViewController.swift line 115 causes this on pageCurl. commenting it out fixes it, but breaks update on the control dots. If you aren't using those and want a page curl, just cloning a copy and commenting that out will do it. If I find a better fix, I will post that. |
Seeing this as well but @swofml4 suggestion works for me since not using the controls |
I see this when I bind If I setup a |
The reason for the bug is because this block instantiates a UIHostingController every time the views are refreshed and state changes. Passing brand new UIHostingControllers to The least invasive way to fix the problem:
This solution has a limitation that you cannot add/remove/reorder Pages dynamically, because the number of cached HostingControllers would get out of sync and potentially cause out of range exceptions. I'll try to issue a PR that adds more dynamic controller caching (and in the right place), but for now this should unblock the majority of scenarios. |
Hey @sjmueller thanks for the catch, I was going crazy with this bug. |
The issue now occurs in iOS 14, even when I bind to a state with initial value 0 😓 |
I just found out that You basically just have to set However, the end result is very nice and stable, so you may want to consider using it as an internal implementation detail for iOS 14. It lets you get rid of all UIKit wrapping, which also makes it run on other platforms as well. This is the code I use in a personal library (https://github.com/danielsaidi/SwiftUIKit). Just let me know if you would like me to provide it to you as a PR:
|
Does anyone found a solution for this bug yet? |
f won't change current page in PagesCoordinator didFinishAnimating everything works fine except flip page by changing currentPage in my project view.
|
#20 This pull request should fix it |
Hi,
When I change the page programmatically, it is animated once. If I swipe to the next page, I get it animated twice, i.e., once with my swipe and again (to the same page) upon release. This ONLY happens if i change the color of the buttons' texts according to the index. If i leave the color as is, it works fine.
Used your demo "OnboardingView" for this.
`struct OnboardingView: View {
}`
Same issue with
wrap: true
.Printout (e.g.,
Current page is 1, going to 0
) is done once, when the page is changed twice.Afraid that I have no idea how to fix this...
The text was updated successfully, but these errors were encountered: