Open MaksGre opened 3 years ago
The PulleyViewController
implements the UIScrollViewDelegate
that will call the setDrawerPosition
function to be called on particular interactions. Is it possible you are calling that animation in the drawerPositionDidChange
delegate method or another delegate method?
Yes, I am starting my animation from drawerPositionDidChange method.
@MaksGre Can you describe where you are calling those animations relative to the pulley delegate methods?
final class BankBuilder {
static func build() -> BankViewController {
let mainContentVC = UIStoryboard.bank.instantiateViewController(AccountViewController.self)
let drawerContentVC = UIStoryboard.bank.instantiateViewController(OperationsViewController.self)
let viewController = BankViewController(contentViewController: mainContentVC, drawerViewController: drawerContentVC)
...
return viewController
}
}
final class BankViewController: PulleyViewController {
var tabBar: TabBarController? {
tabBarController as? TabBarController
}
...
override func drawerPositionDidChange(drawer: PulleyViewController, bottomSafeArea: CGFloat) {
guard pulleyPosition != drawer.drawerPosition else { return }
pulleyPosition = drawer.drawerPosition
switch drawer.drawerPosition {
case .collapsed:
interactor?.request(.didCollapseTable)
tabBar?.didScrollUp()
case .partiallyRevealed:
interactor?.request(.didExpandTable)
tabBar?.didScrollDown()
default: return
}
}
}
final class TabBarController: UITabBarController {
...
func didScrollDown() {
lowerTabBar()
}
...
private func lowerTabBar() {
guard customTabBar.frame.origin.y == tabBarOriginMinY else { return }
var frame = customTabBar.frame
frame.origin.y = tabBarOriginMaxY
animate {
self.customTabBar.frame = frame
}
}
...
private func animate(block: @escaping () -> Void) {
UIView.animate(
withDuration: Appearance.animationDuration,
delay: Appearance.animationDelay,
usingSpringWithDamping: Appearance.springWithDamping,
initialSpringVelocity: Appearance.initialSpringVelocity,
options: Appearance.animationOptions,
animations: {
block()
})
}
...
}
private struct Appearance {
static let animationDuration: TimeInterval = 1
static let animationDelay: TimeInterval = 0
static let springWithDamping: CGFloat = 0.7
static let initialSpringVelocity: CGFloat = 1
static let animationOptions: UIView.AnimationOptions = [.curveEaseInOut]
}
in didScrollUp method about the same code and the same effect
Describe the question When the user swipes drawerViewController I fire my animation to move the custom tabbar, the problem is that my animation somehow gets executed with the drawerViewController swipe animation settings. I checked everything several times. I started my animation without a swipe and then the animation happens correctly, with my settings. If I swipe drawerViewController, then my animation happens with the drawerViewController settings, which are specified in line 510 of PulleyViewController. How can this be explained and circumvented?
Code snippets and helpful information https://yadi.sk/i/U_D2H6Vdd1WyFQ
Pulley Information (optional):
Xcode Information (optional):