Skip to content

Commit

Permalink
Update PanModalAnimator.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
tun57 committed May 12, 2019
1 parent da4c94e commit 13251e1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions PanModal/Animator/PanModalAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ struct PanModalAnimator {
Constant Animation Properties
*/
struct Constants {
static let transitionDuration: TimeInterval = 0.5
static let defaultTransitionDuration: TimeInterval = 0.5
}

static func animate(_ animations: @escaping PanModalPresentable.AnimationBlockType,
config: PanModalPresentable?,
_ completion: PanModalPresentable.AnimationCompletionType? = nil) {

UIView.animate(withDuration: Constants.transitionDuration,
let transitionDuration = config?.transitionDuration ?? Constants.defaultTransitionDuration
let springDamping = config?.springDamping ?? 1.0
let animationOptions = config?.transitionAnimationOptions ?? []

UIView.animate(withDuration: transitionDuration,
delay: 0,
usingSpringWithDamping: config?.springDamping ?? 1.0,
usingSpringWithDamping: springDamping,
initialSpringVelocity: 0,
options: [.curveEaseInOut, .allowUserInteraction, .beginFromCurrentState],
options: animationOptions,
animations: animations,
completion: completion)
}
Expand Down

0 comments on commit 13251e1

Please sign in to comment.