Skip to content

Commit

Permalink
Merge branch 'hotfix/3.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kawoou committed Jun 16, 2017
2 parents a3b1b4b + 9973657 commit 3c2082e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 30 deletions.
80 changes: 54 additions & 26 deletions DrawerController/DrawerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {

private var tapGestureRecognizer: UITapGestureRecognizer?

private var currentOrientation: UIDeviceOrientation = .unknown

/// Gesture
private var gestureBeginPoint: CGPoint = CGPoint.zero
private var gestureMovePoint: CGPoint = CGPoint.zero
Expand Down Expand Up @@ -769,6 +771,39 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
self.delegate?.drawerDidCancelAnimation?(drawerController: self, side: side)
}

private func updateLayout() {

for (_, content) in self.contentMap {
content.updateView()
}

if !self.isAnimating {
for (side, content) in self.contentMap {
if side == .none { continue }

let percent: Float = self.drawerSide == .none ? 0.0 : 1.0

self.willBeginAnimate(side: self.drawerSide)
self.didBeginAnimate(side: self.drawerSide)
self.willAnimate(side: self.drawerSide, percent: percent)
self.didAnimate(side: self.drawerSide, percent: percent)

content.startTransition(side: self.drawerSide)
content.transition(
side: self.drawerSide,
percentage: self.calcPercentage(side: side, moveSide: self.drawerSide, percent),
viewRect: self.calcViewRect(content: content)
)
content.endTransition(side: self.drawerSide)

self.willFinishAnimate(side: self.drawerSide, percent: percent)
self.didFinishAnimate(side: self.drawerSide, percent: percent)

}
}

}


// MARK: - UIGestureRecognizerDelegate

Expand Down Expand Up @@ -1110,38 +1145,31 @@ open class DrawerController: UIViewController, UIGestureRecognizerDelegate {
if let rightSegueID = self.rightSegueIdentifier {
self.performSegue(withIdentifier: rightSegueID, sender: self)
}

/// Events
self.view.addObserver(self, forKeyPath: "center", options: .new, context: nil)
}

deinit {
self.view.removeObserver(self, forKeyPath:"center")
}

open override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()

for (_, content) in self.contentMap {
content.updateView()
}
let newOrientation = UIDevice.current.orientation
guard newOrientation != .unknown else { return }
guard newOrientation != self.currentOrientation else { return }
self.currentOrientation = newOrientation

if !self.isAnimating {
for (side, content) in self.contentMap {
if side == .none { continue }

let percent: Float = self.drawerSide == .none ? 0.0 : 1.0

self.willBeginAnimate(side: self.drawerSide)
self.didBeginAnimate(side: self.drawerSide)
self.willAnimate(side: self.drawerSide, percent: percent)
self.didAnimate(side: self.drawerSide, percent: percent)

content.startTransition(side: self.drawerSide)
content.transition(
side: self.drawerSide,
percentage: self.calcPercentage(side: side, moveSide: self.drawerSide, percent),
viewRect: self.calcViewRect(content: content)
)
content.endTransition(side: self.drawerSide)

self.willFinishAnimate(side: self.drawerSide, percent: percent)
self.didFinishAnimate(side: self.drawerSide, percent: percent)

}
self.updateLayout()
}

open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)

if keyPath == "center" {
self.updateLayout()
}
}

Expand Down
2 changes: 1 addition & 1 deletion KWDrawerController.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "KWDrawerController"
s.version = "3.6"
s.version = "3.6.1"
s.summary = "Drawer view controller that easy to use!"
s.license = { :type => "MIT", :file => "LICENSE" }
s.homepage = "https://github.com/Kawoou/KWDrawerController"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
KWDrawerController
==================

[![Pod Version](http://img.shields.io/cocoapods/v/KWDrawerController.svg?style=flat)](http://cocoadocs.org/docsets/KWDrawerController/3.6)
[![Pod Platform](http://img.shields.io/cocoapods/p/KWDrawerController.svg?style=flat)](http://cocoadocs.org/docsets/KWDrawerController/3.6)
[![Pod Version](http://img.shields.io/cocoapods/v/KWDrawerController.svg?style=flat)](http://cocoadocs.org/docsets/KWDrawerController/3.6.1)
[![Pod Platform](http://img.shields.io/cocoapods/p/KWDrawerController.svg?style=flat)](http://cocoadocs.org/docsets/KWDrawerController/3.6.1)
[![Pod License](http://img.shields.io/cocoapods/l/KWDrawerController.svg?style=flat)](https://github.com/kawoou/KWDrawerController/blob/master/LICENSE)
![Swift](https://img.shields.io/badge/Swift-3.0-orange.svg)

Expand All @@ -17,7 +17,7 @@ Installation
KWDrawerController is available on [CocoaPods](https://github.com/cocoapods/cocoapods). Add the following to your Podfile:

```ruby
pod 'KWDrawerController', '~> 3.6'
pod 'KWDrawerController', '~> 3.6.1'
```


Expand Down

0 comments on commit 3c2082e

Please sign in to comment.