-
Notifications
You must be signed in to change notification settings - Fork 38
Closed
Description
ScrollStackRow allow row's controller view to perform custom animation when hide or show row.
Implementation is based upon the ScrollStackRowAnimatable
. Your view controller should implement the method of this protocol in order to intercept hide/show events and perform custom animations.
public protocol ScrollStackRowAnimatable {
/// Animation main info.
var animationInfo: ScrollStackAnimationInfo { get }
/// Animation will start to hide or show the row.
/// - Parameter toHide: hide or show transition.
func willBeginAnimationTransition(toHide: Bool)
/// Animation to hide/show the row did end.
/// - Parameter toHide: hide or show transition.
func didEndAnimationTransition(toHide: Bool)
/// Animation transition.
/// - Parameter toHide: hide or show transition.
func animateTransition(toHide: Bool)
}
The following example show how it works custom animation inside the demo app:
extension WelcomeVC: ScrollStackRowAnimatable {
public var animationInfo: ScrollStackAnimationInfo {
return ScrollStackAnimationInfo(duration: 1, delay: 0, springDamping: 0.8)
}
public func animateTransition(toHide: Bool) {
switch toHide {
case true:
self.view.transform = CGAffineTransform(translationX: -100, y: 0)
self.view.alpha = 0
case false:
self.view.transform = .identity
self.view.alpha = 1
}
}
public func willBeginAnimationTransition(toHide: Bool) {
if toHide == false {
self.view.transform = CGAffineTransform(translationX: -100, y: 0)
self.view.alpha = 0
}
}
}
The result is this:
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request