Code Monkey home page Code Monkey logo

Comments (4)

ulmentflam avatar ulmentflam commented on May 25, 2024

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?

from pulley.

MaksGre avatar MaksGre commented on May 25, 2024

Yes, I am starting my animation from drawerPositionDidChange method.

from pulley.

ulmentflam avatar ulmentflam commented on May 25, 2024

@MaksGre Can you describe where you are calling those animations relative to the pulley delegate methods?

from pulley.

MaksGre avatar MaksGre commented on May 25, 2024
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

from pulley.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.