diff --git a/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift b/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift index 87c25e4a..0de6f47e 100644 --- a/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift +++ b/Mastodon/Scene/Profile/Header/ProfileHeaderViewController.swift @@ -362,7 +362,7 @@ extension ProfileHeaderViewController { } } - func updateHeaderScrollProgress(_ progress: CGFloat) { + func updateHeaderScrollProgress(_ progress: CGFloat, throttle: CGFloat) { // os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: progress: %.2f", ((#file as NSString).lastPathComponent), #line, #function, progress) updateHeaderBottomShadow(progress: progress) @@ -408,12 +408,12 @@ extension ProfileHeaderViewController { viewModel.isTitleViewContentOffsetSet.value = true } - // set avatar + // set avatar fade if progress > 0 { setProfileBannerFade(alpha: 0) - } else if progress > -0.3 { - // y = -(10/3)x - let alpha = -10.0 / 3.0 * progress + } else if progress > -abs(throttle) { + // y = -(1/0.8T)x + let alpha = -1 / abs(0.8 * throttle) * progress setProfileBannerFade(alpha: alpha) } else { setProfileBannerFade(alpha: 1) diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index 317d0234..267e5bce 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -652,7 +652,8 @@ extension ProfileViewController: UIScrollViewDelegate { // elastically banner image let headerScrollProgress = containerScrollView.contentOffset.y / topMaxContentOffsetY - profileHeaderViewController.updateHeaderScrollProgress(headerScrollProgress) + let throttle = ProfileHeaderViewController.headerMinHeight / topMaxContentOffsetY + profileHeaderViewController.updateHeaderScrollProgress(headerScrollProgress, throttle: throttle) } }