Skip to content

Commit

Permalink
Add @discardableResult attribute to functions that return Animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Daigneault committed Jul 11, 2017
1 parent 52ae301 commit 093bf7c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Pod/Classes/AnimationSugar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import UIKit
- Returns An `Animation` object that can be further modified (e.g. changing an
animation curve) or chained with further animations.
*/
@discardableResult
public func animate(duration: TimeInterval = Animation.defaultAnimationDuration, animations: @escaping () -> ()) -> Animation {
return Animation(duration: duration, animations: animations)
}
Expand Down Expand Up @@ -62,6 +63,7 @@ public class Animation {
- Parameter option: The option(s) to set. E.g. `.withOption(.AnimationCurveEaseOut)`
- Returns An `Animation` object that can be modified or chained with further animations.
*/
@discardableResult
public func withOption(option: UIViewAnimationOptions) -> Animation {
if let options = options {
self.options = options.union(option)
Expand All @@ -78,6 +80,7 @@ public class Animation {
- Parameter delay: The amount of time to delay.
- Returns An `Animation` object to be modified or chained with further animations.
*/
@discardableResult
public func withDelay(delay: TimeInterval) -> Animation {
self.delay = delay
return self
Expand All @@ -89,6 +92,7 @@ public class Animation {
- Parameter completion: A block of code to run.
- Returns An `Animation` object to be modified or chained with further animations.
*/
@discardableResult
public func withCompletion(completion: @escaping (Bool) -> ()) -> Animation {
self.completion = completion
return self
Expand All @@ -110,6 +114,7 @@ public class Animation {
animation to match a view velocity of 100 pt/s, use a value of 0.5.
- Returns An `Animation` object to be modified or chained with further animations.
*/
@discardableResult
public func withSpring(dampingRatio: CGFloat, initialVelocity: CGFloat) -> Animation {
self.springDampingRatio = dampingRatio
self.springInitialVelocity = initialVelocity
Expand All @@ -125,6 +130,7 @@ public class Animation {
- Parameter animations: A block containing changes to `UIView` animatable properties.
- Returns An `Animation` object to be modified or chained with further animations
*/
@discardableResult
public func thenAnimate(duration: TimeInterval = defaultAnimationDuration, animations: @escaping () -> ()) -> Animation {
let nextAnimation = Animation(duration: duration, animations: animations, startNow: false)
nextAnimation.prevAnimation = self
Expand Down Expand Up @@ -273,6 +279,7 @@ extension UIView {
- Parameter duration: The duration of the animation
- Returns: An `Animation` that can be chained or altered.
*/
@discardableResult
public func fadeIn(duration: TimeInterval = Animation.defaultAnimationDuration) -> Animation {
self.alpha = 0.0
return animate(duration: duration) {
Expand All @@ -286,6 +293,7 @@ extension UIView {
- Parameter duration: The duration of the animation
- Returns An `Animation` that can be chained or altered.
*/
@discardableResult
public func fadeOut(duration: TimeInterval = Animation.defaultAnimationDuration) -> Animation {
return animate(duration: duration) {
self.alpha = 0.0
Expand Down

0 comments on commit 093bf7c

Please sign in to comment.