Skip to content
This repository was archived by the owner on Jun 17, 2018. It is now read-only.

Commit 287f995

Browse files
authored
Merge pull request #303 from wwwjfy/no-animation
not call UIView.animate if no animation
2 parents bb73e87 + cdbe03b commit 287f995

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

Pod/Classes/PagingMenuController.swift

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,22 @@ open class PagingMenuController: UIViewController {
175175
pagingViewController.currentViewController = nextPagingViewController
176176

177177
let duration = animated ? options.animationDuration : 0
178-
UIView.animate(withDuration: duration, animations: {
179-
() -> Void in
178+
let animationClosure = {
180179
pagingViewController.positionMenuController()
181-
}) { [weak self] (_) -> Void in
182-
pagingViewController.relayoutPagingViewControllers()
183-
184-
// show paging views
185-
self?.showPagingMenuControllers()
186-
187-
self?.onMove?(.didMoveController(to: nextPagingViewController, from: previousPagingViewController))
180+
}
181+
let completionClosure = { [weak self] (_: Bool) -> Void in
182+
pagingViewController.relayoutPagingViewControllers()
183+
184+
// show paging views
185+
self?.showPagingMenuControllers()
186+
187+
self?.onMove?(.didMoveController(to: nextPagingViewController, from: previousPagingViewController))
188+
}
189+
if duration > 0 {
190+
UIView.animate(withDuration: duration, animations: animationClosure, completion: completionClosure)
191+
} else {
192+
animationClosure()
193+
completionClosure(true)
188194
}
189195
}
190196

0 commit comments

Comments
 (0)