Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cocoapods #96

Open
wants to merge 3 commits into
base: cocoapods
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ public extension UIPanGestureRecognizer {
// MARK: -
// MARK: (UIGestureRecognizerState) Extension

public extension UIGestureRecognizerState {
func dg_isAnyOf(values: [UIGestureRecognizerState]) -> Bool {
return values.contains({ $0 == self })
public extension UIGestureRecognizer.State {
func dg_isAnyOf(_ values: [UIGestureRecognizer.State]) -> Bool {
return values.contains(where: { $0 == self })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ public class DGElasticPullToRefreshLoadingViewCircle: DGElasticPullToRefreshLoad
if shapeLayer.animationForKey(kRotationAnimation) != nil { return }

let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation.z")
rotationAnimation.toValue = CGFloat(2 * M_PI) + currentDegree()
rotationAnimation.toValue = CGFloat(2 * Double.pi) + currentDegree()
rotationAnimation.duration = 1.0
rotationAnimation.repeatCount = Float.infinity
rotationAnimation.removedOnCompletion = false
rotationAnimation.fillMode = kCAFillModeForwards
rotationAnimation.fillMode = CAMediaTimingFillMode.forwards
shapeLayer.addAnimation(rotationAnimation, forKey: kRotationAnimation)
}

Expand Down
14 changes: 8 additions & 6 deletions DGElasticPullToRefresh/DGElasticPullToRefreshView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public class DGElasticPullToRefreshView: UIView {
super.init(frame: CGRect.zero)

displayLink = CADisplayLink(target: self, selector: Selector("displayLinkTick"))
displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes)
displayLink.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
displayLink.paused = true

shapeLayer.backgroundColor = UIColor.clearColor().CGColor
Expand All @@ -141,7 +141,7 @@ public class DGElasticPullToRefreshView: UIView {
addSubview(r2ControlPointView)
addSubview(r3ControlPointView)

NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("applicationWillEnterForeground"), name: UIApplicationWillEnterForegroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(DGElasticPullToRefreshView.applicationWillEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
}

required public init?(coder aDecoder: NSCoder) {
Expand Down Expand Up @@ -175,16 +175,18 @@ public class DGElasticPullToRefreshView: UIView {
} else if keyPath == DGElasticPullToRefreshConstants.KeyPaths.Frame {
layoutSubviews()
} else if keyPath == DGElasticPullToRefreshConstants.KeyPaths.PanGestureRecognizerState {
if let gestureState = scrollView()?.panGestureRecognizer.state where gestureState.dg_isAnyOf([.Ended, .Cancelled, .Failed]) {
scrollViewDidChangeContentOffset(dragging: false)
if let gestureState = scrollView()?.panGestureRecognizer.state {
if gestureState == .ended || gestureState == .cancelled || gestureState == .failed {
scrollViewDidChangeContentOffset(dragging: false)
}
}
}
}

// MARK: -
// MARK: Notifications

func applicationWillEnterForeground() {
@objc func applicationWillEnterForeground() {
if state == .Loading {
layoutSubviews()
}
Expand Down Expand Up @@ -336,7 +338,7 @@ public class DGElasticPullToRefreshView: UIView {
displayLink.paused = true
}

func displayLinkTick() {
@objc func displayLinkTick() {
let width = bounds.width
var height: CGFloat = 0.0

Expand Down