diff --git a/Mastodon/Scene/Onboarding/Welcome/View/WelcomeIllustrationView.swift b/Mastodon/Scene/Onboarding/Welcome/View/WelcomeIllustrationView.swift index 7c153ea9a..317fead61 100644 --- a/Mastodon/Scene/Onboarding/Welcome/View/WelcomeIllustrationView.swift +++ b/Mastodon/Scene/Onboarding/Welcome/View/WelcomeIllustrationView.swift @@ -206,9 +206,8 @@ extension WelcomeIllustrationView { } } - func update(currentPage: WelcomeContentPage, contentOffset: CGFloat) { - // why does it jump back??? - print("\(contentOffset) — \(currentPage)") + func update(contentOffset: CGFloat) { //TODO: @zeitschlag update frames + print(Int(contentOffset)) } } diff --git a/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift b/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift index 1aeaa1770..3b5fa8f57 100644 --- a/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift +++ b/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift @@ -85,6 +85,7 @@ final class WelcomeViewController: UIViewController, NeedsDependency { return pageController }() var currentPage: WelcomeContentPage = .whatIsMastodon + var currentPageOffset = 0 } extension WelcomeViewController { @@ -405,8 +406,11 @@ extension WelcomeViewController: UIPageViewControllerDelegate { guard let currentViewController = pageViewController.viewControllers?.first as? WelcomeContentViewController else { return } currentPage = currentViewController.page - //FIXME: @zeitschlag fix -// welcomeIllustrationView.update(for: currentPage, contentOffset: 1000) + + if let pageIndex = WelcomeContentPage.allCases.firstIndex(of: currentPage) { + let offset = Int(pageIndex) * Int(pageViewController.view.frame.width) + currentPageOffset = offset + } } } @@ -455,8 +459,9 @@ extension WelcomeViewController: UIPageViewControllerDataSource { extension WelcomeViewController: UIScrollViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { - print(scrollView.contentOffset.x) - //TODO: @zeitschlag sync view - welcomeIllustrationView.update(currentPage: currentPage, contentOffset: scrollView.contentOffset.x) + let weirdScrollViewJumpingCorrectionFactor = pageViewController.view.frame.width + let contentOffset = CGFloat(currentPageOffset) + scrollView.contentOffset.x - weirdScrollViewJumpingCorrectionFactor + + welcomeIllustrationView.update(contentOffset: contentOffset) } }